Rock, paper, scissors


#1

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

i keep getting syntax error, unexpected token else.
i already checked for capitalization errors, and every other error i can think of and am obviously missing something,
HALP.


#2

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

you need to look over the syntax of your code and maybe review the syntax of the if/else statement. Im sure @haxor789 would be glad to further explain.


#3

First of all you miss a closing } for your function. But the more confusing thing seem to be how the else if's are constructed.
The overall idea is that you decide who wins by having a look at choice1 and inside the possible options of choice1 nest the possible options of choice2. An example for this can be found in the hint of 6/9

    else if (choice1 === "rock"){
        if (choice2 === "scissors")
        return "rock wins"
        else {
            return "paper wins"
        }
    }
``` 
This case is acutally pretty much like it. Do you know why you can omit the {} after if or was this without purpose? Here is some further explanation about it:
http://discuss.codecademy.com/t/conditions-blocks-and-semicolons/2176?u=haxor789

And the second case its went a bit wrong:
```
    else if (choice1 === "paper"){
        if (choice2 === "rock"){
            return "paper wins"
            else {
                return "scissors wins"
            }   
        } 
    }

here you nest the else inside of the if so they are not connected on the same level which then gives you the error for not being able to handle a solitary else.