7/9 SyntaxError: Unexpected token else


#1

I keep getting a syntax error - I've double checked my semicolons and brackets and I can't figure out where I've gone wrong...here is my code for 7/9

var compare = function(choice1, choice2) {
    if (choice1 === choice2) {
        return "The result is a tie!";
    } else if (choice1 === "rock") {
        if (choice2 === "scissors") {
            return "rock wins";
        } else {
            return "paper wins";
        }
    }
} else if (choice1 === "paper") {
    if (choice2 === "rock") {
        return "paper wins";
    } else {
        return "scissors wins";
    }
}

#2
else if (choice1 === "rock") {
        if (choice2 === "scissors") {
            return "rock wins";
        } else {
            return "paper wins";
        }
    }
} else if (choice1 === "paper") {

you have one additional } here. So the one before else if (choice1 === "paper") { closes your function already, so the else if is not part of it and therefor not connected to any if.


#3

If you have a good look,
you are closing the function-body directly AFTER your first ELSE-IF
you got 3 closing curly-bracket-}
-1 to close the ELSE
-2 to close the ELSE-IF
-3 to close the FUNCTION-BODY

Please have a look at
http://www.codecademy.com/forum_questions/559dcb4be39efe550f00006b


#4

thank you! That worked! I think I'm finally getting it