Stuck on # 5


#1

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

while(slaying === true){
    if(youHit=== 1){
     console.log ("You hit the dragon" )
       var totalDamage = damageThisRound + totalDamage ;
    }
       if(totalDamaga <= 4){
           console.log("You have slayed the Dragon")
           slaying = false;
       }
           else {
               youHit = Math.floor(Math.random() * 2);
       }
}
else {
   slaying = false;
    console.log("dragon defeated you")
    }
}

keep saying
Oops, try again. There was a problem with your syntax.


#2

this if condition:

if(youHit=== 1){
     console.log ("You hit the dragon" )
       var totalDamage = damageThisRound + totalDamage ;
    }

remove the }, this way you have a if/else with nested if else:

if (condition){
   if (condition){
      
   } else {

   }
} else {

}

your } prevents the properly nested if/else (as shown above)

you misspelled totalDamage in your second if condition

you should check if the damage is greater or equal to 4, currently you check if the damage is smaller or equal then 4