What if choice1 is paper?


#1



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


SyntaxError: expected expression, got keyword 'else'


Replace this line with your code. 
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";
    }
}

Hi, guys! I'm stuck in this exercise and I don't find the mistake (actually, I don't see it :confounded: ) Someone could help me? Thanks! :slight_smile:


#2

take a look at this:

else if (choice1 === "rock") {
        if (choice2 === "scissors") {
            return "rock wins";
        }
    } // this one
        else {
            return "paper wins";
        }
}

i added a comment to the code, as you can see, the curly bracket in question closes your else if after your if, while the else should also be inside the else if. Remove the } where i commented: this one


#3

Thanks! It's done and working! Although I needed after half an hour to find another mistake (to close the }... at the end of the code). Thanks again! :slight_smile: