'if else' syntax error


#1

its saying there is something wrong with the else if statement

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

}


#2

The if/else if/else syntax..

if (condition) {
 /* YourCode */

} else if (condition) {
 /* YourCode*/

} else {
 /* YourCode*/
}

If you match this syntax with your code,you will able to purify the mistakes you made.

I'll point you tho..

Problem1.

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

Where is starting curly bracket?

Problem2.
else if(choice1 === "rock");
semicolon after it? (Match it with syntax)

I hope it helps!


#3

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