"Unexpected token else" Can't figure out why


#1

This is my code... I can't understand why it says this when the instructions ask for another else statement. Or is it an if else statement they are looking for?

var slaying = true
var hitDragon = Math.floor( Math.random () * 2)
var damageThisRound = Math.floor ( Math.random () * 5 + 1 )
var totalDamage = 0
while (slaying) {
if (hitDragon) {
console.log( "You hit the dragon and did" + damageThisRound + "damage!");
total.Damage += damageThisRound;
}
if (totalDamage >=4) {
console.log("The dragon is dead!");
slaying = false

         else {
            hitDragon = Math.floor(Math.random) *2 );
        }
           else {
                console.log("The dragon defeated you!");
        }
        slaying=false
    };

#2

Hey @jbrownbear,

You forgot to put a '}' there. :smiley:


#3

Good eye! I put in the missing curly bracket, but it still isn't running. What is wrong with my else statement?


#4

@jbrownbear Well,

Do you know what else if loops are? You probably learned them already, but you need to put else if instead of repeating if loops and else loops :smiley: