SyntaxError: Unexpected token else


#1


https://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/1/3?curriculum_id=506324b3a7dffd00020bf661#


This code keeps returning this error: "SyntaxError: Unexpected token else". I'm not sure where the error is and I would appreciate some 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!";
        }
    }
    else if (choice1 === "paper"); {
        if (choice2 === "rock") {
            return "Paper Wins!";
        }
        else {
            return "Scissors Wins!";
        }
    }
}


#2

There we already similar error with other person I saw before.
Dont use ; on for and if. You only need {} without semicolon.


#3

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