Unexpected keyword else


#1

What is wrong here?

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 win";

    }

};


#2

@c-poulsen

Close your else if statement here.

Close your else if statement here too.

Hope this helped! :wink:


#3

Hi and remove the = after the return statement

return = "paper wins";
return = "scissors win";

#5

I figured it out
If anybody needs it this is my working solution:

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

};
};