Rock, Paper, Scissors Lesson 6


#1

I am getting an error in my syntax, even after I finally looked at the hint and copied and pasted the code right from it! Please help. Thanks!

Instructions are:
1. Inside the compare() function under the existing code, write an else if statement where the condition is choice1 === "rock".
2. Inside this else if statement, write an if / else statement. If choice2 === "scissors", return "rock wins". Else, return "paper wins".

Existing code is:
var compare= function(choice1, choice2) {
if(choice1 === choice2) {
return "The result is a tie";
}

So the new code, in addition with the existing code should be:
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"
}
}

Here is the 'hint' code that was provided:
if(choice1 === choice2) {
return "The result is a tie";

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


#2

You have four equals, when you should probably only use two.


#3

Thank you!!! Evil eyes are evil...

Original Code:
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"
}
}

Corrected Code:
var compare= function(choice1, choice2) {
if(choice1 === choice2) {
return "The result is a tie";

} else if(choice1 === "rock") {
if(choice2 ==== "scissors") { removed extra =
return "rock wins"
} else {
return "paper wins"
}
}