What if choice1 is paper?


#1


https://www.codecademy.com/en/courses/javascript-beginner-en-Bthev-mskY8/1/3?curriculum_id=506324b3a7dffd00020bf661

else if(choice1 ==="rock") {
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"
}
}
}

I have big but very big problem.Every time when i click appears SyntaxError: Unexpected token else its driving me crazy


Replace this line with your code.
ed toke


#2

It should look like this:

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


#3

Still doesn't work its going on my nerve !!!!!!


#4

Try this :wink: Should work if not reset

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"
}
}
else
{
if(choice2 === "rock")
{
return "rock wins"
}
else
{
return "scissors wins"
}
}
}


#5

Nope its not working i'm tryed this couple a times nothing happend.This Java sucks!!!


#6

Show me my code in your browser, because it works fine in mine. Maybe switch browsers, that can fix it.


#7

var userChoice = prompt("Do you choose rock, paper or scissors?");
var compare = function(choice1, choice2) {
if(choice1 === choice2) {
return "The result is a tie!";
}

else if(choice1 ==="rock") {
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";
}
}
}


#8

iv tryed your way nothing happends


#9

I'm using Chrome no way


#10


#11

You have two extra curly braces in your code. (Look for //}).

var userChoice = prompt("Do you choose rock, paper or scissors?");
var compare = function(choice1, choice2) {
if(choice1 === choice2) {
return "The result is a tie!";
}

else if(choice1 ==="rock") {
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";
}
};
//}


#12

Accurate. Good luck!