7/9 Unexpected Token Else


#1

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!";
}

The first half passed though (lines 5-9) but when I replicate it and change the strings it is giving me the Unexpected token else, error. Will someone please explain? I have been working on this one for a long time now and I am not understanding what I am doing wrong.


#2

You are missing the opening-curly-brackets-{ after your ELSE
and then missing a closing-curly-bracket-} with which you close the ELSE-IF
and at the end a missing closing-curly-bracket-} with which you close the compare-function-body

Have a read
http://www.codecademy.com/forum_questions/559dcb4be39efe550f00006b
and concentrate on the build of the IF ELSE-IF statement structure...


#3

Thank you! I got it. :smile: