SyntaxError: unexpected token else


#1


Build "Rock, Paper, Scissors"
7. What if choice1 is paper?


Hey,

For the exercise I had come to the point where I had to add another "else if", namely the one when choice1 would equal "paper".
In my mind I had to almost exactly copy the code I typed above, but everytime I try to save & submit I get the following error:
SyntaxError: unexpected token else
I have stared myself to death where the fault could be, but I can't seem to find it.
I hope one of you can help me solve this error.


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

this code:

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

closing curly bracket (}) of else if shouldn't have semi-colons.


#3

Oh my god, it really is that simple. Really weird, because when there was only one 'else if' it had no problem with the semi-colons.
Thanks for the help!


#4