Dragon slaying


#1

It says that i dont log in console who wins....

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 === true)
                {
                console.log("Congratulations, you hit the dragon!"); 
                }
                    else {
                         console.log("The dragon defeated you.");
                          }
        }

#2

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


#3

you initialize slaying as false, so the while loop never runs


#4

Thanks, havent figure that out


#5

did you figure it out? If problems persist, post an updated version of your code and i will help you further


#6

yea, i experesed myself on a wrong way. Meant to say that i didnt figured it out earlier . Thanks again


#7

can i see an updated version of your code?


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.