5 help me check it out ,what is wrong?


#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(totalDamage >= 4) {
    console.log(slew the dragon);
    slaying = false;
}
    else {
       youHit = Math.floor(Math.random()*2);
    }

} else {
console.log("You lose!");
slaying = false;
}
}


#2

Hi,

you set a } to much remove it here

if(youHit) {
    console.log("You hit the dragon");
    totalDamage += damageThisRound;
} // This one here is to much 
if(totalDamage >= 4)