What if choice 1 is rock help please


#1

The following is the 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";
};

I'm getting a syntax error yet I'm not sure why


#2

var compare = function(choice1, choice2) {  //did you close this function?
if (choice1 === choice2) {
return "The result is a tie!";
} else if (choice1 === "rock") {  // same here
if(choice2 === "scissors") {
return "rock wins";
} else {
return "paper wins";
};

#3

I'm not sure if I did and if not how I would


#4

just add } brackets after closing else statement


else {
return "paper wins";
};
} // close else if
} //close function

so now you just need two } brackets


#5

Thanks so much it works now =)


#6

need some help with my code.


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.