I am completely stumped on what if choice 1 is paper!


#1



https://www.codecademy.com/en/courses/javascript-beginner-en-Bthev-mskY8/1/3?curriculum_id=506324b3a7dffd00020bf661

I am completely and utterly stumped with this lesson! With this code i keep getting SyntaxError: Unexpected token else. I have literally no idea what im doing wrong! I'm in desperate need of help!

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

    }
}


#2

You're having an extra curly bracket there which seems to then close the function. Whereas, other conditions are in it.

Hope this helps! :slight_smile:


#3

OH MY GOD! 1 freaking curly bracket caused me that much frustration!!! Thanks so much though!


#4

You're welcome.

Have fun coding! :slight_smile:


#5

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