Help with what if choice 1 is paper?


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

#2

it says system error: unexpected end of input.


#3

Seems like your missing an } to close the function.


#4

I put another } to close the function and now it says unexpected token else. I have been on this step for ages, can't figure it out.


#5

Could you post the updated code?


#6

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

#7

Well now you closed the function too early after the if, I meant to add the } at the very end of your code to close the function.