"What if choice1 is rock" code issues


#1

Can someone help? I've tried variations of this code and looked for help on here but I keep getting error messages. Thanks so much!

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

Errors: "SyntaxError: Unexpected token else," and "There was a problem with your syntax."

var compare = function(choice1, choice2) {
    if (choice1 === choice2) {
        return "The result is a tie!";
    }
    else if (choice1 === "rock") {
        if else (choice2 === "scissors") {
            return "rock wins";
        }
        else {
            "paper wins";
        }
    }

#2

Look at what you wrote here:

and here:

See the problem?


#3

Take a look;

var compare = function(choice1, choice2) {
    if (choice1 === choice2) {
        return "The result is a tie!";
    }
    else if (choice1 === "rock") {
        if else (choice2 === "scissors") { // "if else"?? change this.
            return "rock wins";
        }
        else {
            "paper wins";
        }
    }
 // add a closing brace here }

#4

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