6/9 Unexpected token else


var compare = function(choice1,choice2) {
if (choice1 === choice2);{
return "The result is a tie!";
} else if (choice1 === "rock") {
if (choice2 === "scissor");{
return "rock wins";
} else { return "paper wins";}

Any help is appreciated, I've been trying different things with no success for about a half hour or so now. Thanks


You are using a semi-colon-; in IF ELSE-IF statement structure.
if (choice1 === choice2);{
For the Javascript Interpreter a semi-colon-;
is an End-of-Statement indicator,
leading to the REST of statement is NOT evaluated.

Please read
and concentrate
-1 of the build of the IF ELSE-IF statement structure
-2 the truth-Table


As @leonhard_wettengmx_n already says the semicolons after conditions are a problem, I wrote a longer post ofter here:

@lolman What is the problem about this line?
@danimal1 Seems like your also missing a } after the very end to close your function.



Nothing is wrong with this line, I made a mistake and I do apologize for the confusion.


No problem. Then maybe delete them so no bypasser gets confused :smile:


I read you post and found it helpful. I was able to get rid of "unexpected token else", but now I'm getting "Oops, try again. Your code returned 'paper wins' instead of 'rock wins' when the inputs are rock and scissors". Thanks again for the help.


Oh yes here it needs to be "scissors" not "scissor" so as the case is not matching (even so it's just a little bit) it chooses the default case.


Thank you so much! This helped a lot!