Rock, paper , scissors


#1

what is wrong with my code? pls helpp!

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

So you open your variable compare, but from what I can see, you don't close it. :slight_smile: You just have so many curly braces that it's hard to notice.


#3

where should i close the variable compare at?


#4

Sorry, I meant function! You define it as a variable, but really it's the function compare. Just at the bottom after

because those bracket closed the else and else if statements.


#5

I tried removing the last curly bracket but it still cant work! :frowning:


#6

No you want to add another one, so maybe add two back?


#7

Awesome it works! Thanks alot kyleaw!


#8

No problem! Glad to help. :slight_smile:


#9

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