2 Declare your variables


#1



https://www.codecademy.com/courses/javascript-beginner-en-mrTNH-6VIZ9/0/2?curriculum_id=506324b3a7dffd00020bf661


I can't understand why the loop is infinite can you please tell me?


Replace this line with your code. 
var slaying=true
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!");
        totalDamage=+damageThisRound
        if (totalDamage>=4) {
            console.log("Dragon has fallen, now it is time to get the girl.");
            slaying=true;
        }else{
            youHit=Math.floor(Math.random()*2);
        }
    } else {
        console.log("You missed!");
    }
    slaying = true;
}


#2

slaying is never set to false.


#3

Hi this part

if (totalDamage>=4) {
    console.log("Dragon has fallen, now it is time to get the girl.");
    slaying=true;
}

here if your totalDamage are great or equal to 4 that mean you kill the dragon and get the girl so you should put slaying to false... to end the while loop...


#4

Ah ok thx alot it confused the day lights out of me there.