Why is this code not running? Unexpected end of input


#1

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

#2

You need to remove ( before return


#3

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


#4

Your else if syntax is incorrect

else if(something) {
   //run something 
}

#5

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


#6

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"


#7

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...


#8

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


#9

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


#10

Got it, thanks guys! Those damn curlys got me