7. What if choice 1 is paper? - Unexpected token else


#1


Replace this line with your code. Do not remove the backticks.


#2

Paste in your code so we can help, use this format

```

  replace this line with your code, leave backticks

```

#3

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


#4

Hi this part you should remove one } after you if statement and add one after the else statement for the closing of your else if statemtent

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

and then this part just remove the one } after your if stament

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

#5

Amazing, thank you for your help


#6

A post was split to a new topic: I have no idea what is wrong, still: "SyntaxError: Unexpected token else"