Build Rock, Paper, Scissors, Exercise 7


#1

What is wrong with the code, I just can't find as I have been looking all night.

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


#2

See anything amiss with this?


#3

Thank you for your time, I appreciate you helping out.

The only thing I can think of is the removal of the bracket, so I tried doing so and the result is still the same. :

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


#4

Be sure to wrap the return statement in code block braces, otherwise the else if is unexpected.


#5

This line,

and this line,

are both missing the opening brace after the conditional.