I can't find the error in my code, someone please help!



SyntaxError: Expected '{'

Replace this line with your 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"}}


The function body is missing curly braces...

var compare =  function (choice1, choice2) {



Space is cheap and white space is a big help when it comes to readability and debugging. Don't be afraid to use it, especially with curly braces. At the very least, give closing braces their own line and use indentation to help visualize the nested levels.


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