What if choice1 is paper? Help!


#1

stuck here!!! can someone tell me whats wrong, thank you

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

Oops, try again. There was a problem with your syntax. SyntaxError: Unexpected token else


#2

Hi @ernesto2013,

Please see the code sample below to assist. You were subject to a couple of pesky paren gremlins, I indented the code to help make this more visually simpler to see the troublesome areas.

var compare = function(choice1, choice2){    
    if(choice1 === choice2){
        return "The result is a tie!"; //added semi for neatness
    }
    else if(choice1 === "rock"){
        if(choice2 === "scissors"){
            return "rock wins";
        }
        else {
         return "paper wins";
        }
    } //missing the closing paren for else if
    else if(choice1 === "paper"){
        if(choice2 === "rock"){
            return "paper wins";
        }
        else {
            return "scissors wins";
        }
    } //missing the closing paren for else if
}; //added semi for neatness