4. yhe first if statement


#1

var slaying = true;
while(slaying) {
slaying = false;
}
var youHit = Math.floor(Math.random() *2);
var damageThisRound = Math.floor(Math.random()*5 + 1);
var totalDamage = 0;
while (slaying) {
if (youHit) {
console.log("You hit the Dragon");
} else {
console.log("The Dragon deteated you");
}
slaying = false;
};

it doesn't work please help


#2

@pascac,
With the code

var slaying = true;
while(slaying) {
    slaying = false;
}

you are modifying the slaying variable
from a Boolean Value of true to false

As the slaying variable has the Boolean Value false
the =second-while= code-block is NOT executed.

Change your code

var slaying = true;
//while(slaying) {
//    slaying = false;
//}