Whats wrong with my syntax? (choice 1 = rock)


#1

Ive been checking my code for hours and i cant seem to find whats wrong. Can someone please help?

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

};

Thanks in advance!


#2

Go through your code and make sure that for every opening brace ({) there is a matching closing brace (}) and vice versa


#3

Yea, I've just looked at it and the brackets match up. I can't figure out what else could be wrong tho.


#4

You're missing a couple of braces. You need an opening brace after if(choice1 === choice2) {

and another closing brace before the final }; to close your else if statement.

Here's how it should look:

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