What if choice1 is scissors?



I have a Syntax error, but i am not sure my code is right anyway. But immediately i can not look through anymore. can anyone help me?

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 (choice2 === "rock") {
return ("paper wins");    

else {
return("scissors wins");

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

else {
return ("scissors wins");




What's the syntax error?


Check the comments above. Then go back to your else if statements for choice1==="rock" and choice1==="scissors". The syntax there is close to being correct. Use them as a guide for your else if choice1==="paper" statement.


Oops, try again. There was a problem with your syntax.


SyntaxError: Syntaxfehler


hey thank you for your help, i tried to apply your tips but I do not really get what you mean.
I can not really think through it...
Ich deletet all parantheses for the Returns
I will try to think through it on top of that


Now i could think through it and I get it! Without your Explanation I propably wouldnt have get it :smile:
Because of you I can recognize what the code is for at all! Thank you very much !


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