Why is this code not running? Unexpected end of input


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


You need to remove ( before return


Sorry yes, I caught that and edited the post. now it's giving me an unexpected end of input error


Your else if syntax is incorrect

else if(something) {
   //run something 


You forgot to close you curly braces. Try to add a closing curly braces at the end of your code.


Thanks for the response. I thought I did that-i put conditions after each else if and if statements. E.g. else if (choice1 is rock)
and if (choice2 is scissors), return "rock wins"


Yes, I do have a closing curly brace but it's a few lines down from the last line of this set of codes and it didn't copy. I even moved it up to see if it would solve the problem and unfortunately it didn't. I'm really puzzled...


You do have the condition but you don't have the curly brackets


Here, for your better understanding how important curly braces are.


Got it, thanks guys! Those damn curlys got me