Rock Paper Scissors. Expected identifier instead saw 'else'


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



You else if block is not inside of the function.

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


Ah yes! I ended it with this

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


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


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