Can someone please help me understand what's wrong with my code?


#1


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


I don't understand what's wrong with my code, I wrote it the way it is in the hint box but it says: SyntaxError: missing } after function body, can someone help me please!


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


#2

The error message is telling you what is missing from your function, a curly brace }

If you look at the code inside the function, all the if and else if statements have correct syntax. To close a function, you need that last } to complete the compare function.


#3

Oh ok, thank you so much for your help!!


#4

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