Oops, try again. Does your second 'if' statement check to see if totalDamage is greater than or equal to 4?


#1

var slaying = true
var 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 the dragon!")
totalDamage += damageThisRound
if(totlaDamage>=4){
console.log("the player slew the dragon")
slaying = false
}else{
var youHit = Math.floor(Math.random()*2)
}
}else{
console.log("dragon defeat you")
}
slaying=false
}
I don't know why computer keep telling me that, is there any thing wrong?


#2

@netjumper50137,

Have a close look at

totlaDamage


#3

hahaha i didn't notice that... thank you....