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


#1

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


#2

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.


#3

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


#4

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


#5

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


#6

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