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


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


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.


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


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