Where did i screw up on the 1st if?


it says that i need to console.log a message to state whether or not they won

youHit=Math.floor(Math.random() * 2)
damageThisRound=Math.floor(Math.random()*5 + 1)
    if (youHit === true) {
        console.log("you win!");
        console.log("dragon defeated you!");
    slaying = false


the while loop will never execute since you declare slaying on line 1 and set it to false, try setting to true

because the loop doesn't execute, nothing get logged to the console


Well there are few problems in there.

  1. You don't use ; behind the code lines. (just a note)

Number 1 - true true in number equals to 1
Number 2 - false false in number equals to 0

With youHit=Math.floor(Math.random() * 2) you are saving number 0 or 1 on random in variable youHit so you can get true or false.

You set variable slaying to be false which won't even trigger the while loop because while will go while slayin is true.


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