Lesson 7: Syntax Error: Unexpected Token Else


#1

Hello people! Could use a bit of a hand with this. I have been banging my head against the desk for a good 30 mins trying to figure out where I went wrong.

I am on lesson 7, and it keeps on giving me Syntax Error: Unexpected token else

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

Thanks!


#2

this if statement is not closed - missing curly bracket


What if Choice 1 is paper? Syntax error - unexpected keyword 'else'
#3

THANK YOU SO MUCH!:grin:


#4

You're welcome :green_heart:

Happy Learning :slightly_smiling:
Happy coding !