5. The second 'if' statement «Where is the infinite loop?»


#1



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


When I try to defeat the dragon my browser crashes


var slaying= true
var youHit= Math.floor(Math.random() * 2)
var damagedThisRound= Math.floor(Math.random()*5 + 1)
var totalDamage = 0 

while(slaying) {
    if(youHit) {
        console.log("You hit the dragon!")
        totalDamage += damagedThisRound
        if(totalDamage >= 4) {
            console.log("Congratulations, you defeated the dragon!")
        }else{
            youHit= Math.floor(Math.random() * 2)
        }
    }else{
        console.log("The dragon defeated you")
        slaying= false
    }
}


#2

you need to add

slaying= false

after
console.log("Congratulations, you defeated the dragon!")
slaying= false //here


#3

thank you
I don't believe I didn't notice