7. What if choice1 is paper?


#1

It's saying I have a "SyntaxError: Unexpected token else" but I don't see the issue.

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."
}

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


#2

Return statements end with a semicolon. Example: return "The result is a tie!";


#3

Even with the semicolons in it keeps saying "SyntaxError: Unexpected token else" so it can't be the semicolons.


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

else if (choice1 === "paper") {

here the 2nd else if is still inside of the {} of the first which means you have an else if after an else which doesn't make sense.


#5

Change your last else if statement to just else because it's the last condition.
Also make sure you have a semicolon at the end of each return statement.


#6

Show all of the code please.