HELP What If Choice 1 Is Paper - Build Rock, Paper, Scissors


My code just keeps saying "SyntaxError: Syntax error" and I can't think of anything else to change. Any advice?

var compare =function(choice1, choice2){

//if choices are the same
if (choice1 === choice2) {return "The result is a tie!";}

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

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


check after your else if statements, anytime the compiler runs across a semi-colon it ends that segment of code. So as you run through if,else if , else statements check your semi-colons.


if i put:

return 1;

this would not work and would need to be

return 1;


As @bobsyc wrote, I made a longer text about this topic over here:

that tries to explain what happens due to the semicolon.


Worked out for me this way

var compare = function(choice1, choice2) {
if (choice1 === choice2) {
return "The result is a tie";

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

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