7. What if choice1 is paper? Help!


#1

I don't know where the error is in my code. I'm pretty sure it's probably one of the brackets - can anyone help please?? Been looking at this for a while now and I still can't seem to fix it.

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


#2

In the above else if codeblock, what would execute from an empty bracket set? You should remove the closing bracket there to make the choice2 return statements available.

On both lines, after your conditions, you insert a semicolon before the bracket. Remove these and then examine all of your compare function code to make sure you have closing brackets where necessary. You are missing 2. I won't say where.

Also, here's a link that may help clarify semicolon usage:

https://www.codecademy.com/blog/78


#4

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