6/9 keeps saying rock wins instead of paper


#1

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";
}
}
Shows rock wins instead of paper. Thoughts?


#2

Well, first of all, there's supposed to be a bracket after the if statement in the else if statement, and I do not know why it shows that rock wins, when it is inside a function and you returned it, not send it to the console.


#3

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

};

It's now saying unexpected token else


#4

Check this line of code for me

Do you see the same problem as I? I hope this helps


#5

This is my code: Here: Compare:

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


#6

The problem is the semicolon after your conditions, wrote a post about it over here:


#7

Found it! Thank you everyone!