Dragon slayer #4


Hi all,

I keep getting this error message

Oops, try again. Make sure you log a message to the console to let the player knows if (s)he won or lost!

Here's my code:

var 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!");
    } else {
        console.log("You missed!");
    slaying = false;

Any suggestions?


your loop will never run, since slaying you define on line 1 is false.

you should set slaying to true on line 1, so the loop can run once.


Thanks for the suggestion! It now works