I checked both solutions in the forum and still cannot find the error


#1

I scanned this sooooo many times I checked both solutions in the forum and still cannot find the error, help 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");
}
}
}

else if (choice1 === "paper") {
if (choice2 === "rock") {
return "paper wins";
}
else {
return "scissors wins"
}
}
}


7. What if choice1 is a paper? | "SyntaxError: Unexpected token else"
#2

Hi this part you have more } than you need remove one } after the else statement

else if (choice1 === "rock") {
    if (choice2 ==="scissors") {
        return ("rock wins");
    }
    else {
        return ("paper wins");
   }
}
} <== this one

#3

@ajaxninja44654

Problems come from here

First, you close the if statement's curly brackets (check). Second you close the else statement's curly brackets (check). Third, you close the else if statement's curly brackets (check). And finally comes an unexpected } that closes nothing (problem).

First, you close the if statement's curly brackets (check). Second you close the else statement's curly brackets (check). Third, you close the else if statement's curly brackets (check). And finally, you close your compare function variable with a missing semicolon (problem).

Hope this helped you!:wink:


#4

woo! thank you guys!