What if choice one is paper? Can't find syntax error


I'm having trouble finding the syntax error. Any help is appreciated!

/*var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
	computerChoice = "rock";
} else if(computerChoice <= 0.67) {
	computerChoice = "paper";
} else {
	computerChoice = "scissors";
} console.log("Computer: " + computerChoice);*/

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


You could remove the code and paste parts back one small piece at a time, running it each time. When the syntax error appears the problem is likely in what you just added.

You can also run the code in a different interpreter that has more verbose error messages (like line number for where the syntax error occurred)

It might also be easier spot just by eyeball if you fix your indentation and/or while doing said fixing since it makes you go through the code.


Which interpreter do you suggest using???
Thanks so much!


Any really. Your browser has one unless you're using something incredibly spartan. You can install nodejs. There are online ones.


You put plus signs instead of equal signs. You also forgot the s on scissors.


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