Syntax error in 'the second if statement'


#1

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

Hi,
in this section i had this error message: "SyntaxError: Unexpected token else"
for this code:

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("Hit!")
            if (totalDamage >= 4) {
            console.log("You slew the dragon!");
        }
            else {
            youHit = Math.floor(Math.random() * 2);
    }
    else {
        console.log("Miss! You lose!");
    }
    slaying = false
}

totalDamage = totalDamage + damageThisRound

What went wrong?


#2

There should be an else if then an else last.

You could have many else if.