Please Help... Syntax error


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


#2

else if(choice1 === "rock") {
if(choice2 === "scissors")
return "rock wins";
} 
else {return "paper wins";
}
/* need to close else if */
else if (choice1==="paper")

you need to close your else if choice1 is rock, you didn't. Add a } where i placed a comment


#3

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

};

That is the new code, still have syntax error.


#4

now you are closing the else if after if, while i said in my earlier answer you should close it after else.

You do see the structure you are making, right? A else if with a nested if and else


#5

Oh, ok, thanks. :relaxed:


#6