Rock Paper Scissors


#1

Hi. Can anyone find where my syntax (unexpected "{") is off here. And if you do, can you provide me with some insight as to where I am going wrong. This is driving me nuts. Didn't even look at it for a day but obviously I did not return with a clear head! Thanks

`/*var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if(computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
} console.log("Computer: " + computerChoice);*/
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 if (choice2==="scissors"){
return "scissors wins."}
}

        
  


      
 
`

The first part of the code, the part commented out did work. I thought I was following the same logic.
Thanks Again.


#2

@mccbjnn
Hi, look at line 17 of your code:
}
Should have a semicolon at the end of it because you created the function compare with a variable;
var compare=function(choice1,choice2) {
Also, remove the extra curly brace at the end of your code because you already closed it;
else if (choice2==="scissors"){
return "scissors wins."}
}

Hope this helped you.