Not sure what is happening


#1

Okay here is my code:

slaying = false;
youHit = Math.floor(Math.random() * 2);
damageThisRound = Math.floor(Math.random() * 5 + 1);
totalDamage = 0;
while(slaying) {

if (youHit) {
    console.log("You hit!!");    
}

else {
    console.log("You missed!");        
}

slaying = false;

}

And now it is saying that I didn't make the program log a message to the player when clearly I did.
Help please and thank you.


#2

you declare slaying here and give it a value of false:

slaying = false;

then your while loop will evaluate to false, so your loop doesn't run, so nothing is logged


#3

Thank you. This solved the problem.


#4