6 choice1 is rock


#1

Not sure what's wrong. This is the error:

Syntax error: unexpected token else


if(choice1 === choice2) {
    return "The result is a tie!";

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


#2

HI you didn't close the first if statement

if(choice1 === choice2) {
    return "The result is a tie!";
#here add the }

then add one more at the end for closing the compare function


#3

Thank you! I figured the problem out. Thanks a lot!


#4

How did you solve it? It keeps saying me "unexpected end of input" and I have no idea why
Here's 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";
}
};


#5

I had to add an extra close bracket ( } ) at the end to complete it.


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.