Build "Rock, Paper, Scissors", syntax error?


I'm sure it's probably something really simple but could anyone help?

Instructions are:

Let's code our outline from above:

Inside the compare() function under the existing code, write an else if statement where the condition is choice1 === "rock".
Inside this else if statement, write an if / else statement. If choice2 === "scissors", return "rock wins". Else, return "paper wins".

...and my code:

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


...meanwhile the error is:

SyntaxError: Unexpected token if

Presumably something with an if statement?


Seems like your missing the {} for your function so instead of a { it encounters an if.