Lesson 2 Dragon slayer PL help Save & submit code not working


#1

Here is my 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 croaked, congrats you just killed more wildlife, your ansestors must be pround with you for making another species extinct!");
            slaying=true;
        }else{
            youHit=Math.floor(Math.random()*2);
        }
    } else {
        console.log("You missed!");
    }
    
}

#2

@csscoder68873,
You will want to get out of the WHILE loop
if totalDamage>=4
by setting the variable slaying to false