Rock Paper Scissors. Expected identifier instead saw 'else'


#1

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


Expected identifier instead saw 'else'. There must be a syntax problem I'm not seeing. I could use another pair of eyes, thanks!

r 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

You else if block is not inside of the function.

also make sure you used var keyword when defining the compare function.


#3

Ah yes! I ended it with this

correct? Thanks! Also bad copy paste that's why var looks like r :P. Thanks


#4

You should mark greentreemee's answer as the solution. :relaxed:


#5

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