What if choice1 is rock?


Can anyone tell me where I'm going wrong?


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


just look this

else if(condition){
return somthing


The error message gives a hint at the iissue... The function is not closed. Add one more closing brace to the bottom of the code.


Thank-you. That did the trick. I always get so confused with braces, brackets, and semicolons and how to use them properly.


Now you know one place to not use them. The same goes for any structure with a parameter list and a code block.

if () {} else if () {} else {}

while () {}

switch () {}

function () {}

for () {}

and never at the end, either. When a statement has = in it, it ends with a ;

var myFunction = function () {};

var myObject = {};

var a = "some value";

Statements that contain function call expressions get one...



One while statement does get a semi-colon at the end, do..while:

do {} while ();

It will eventually get sorted out in time. Focus on concepts for now and the syntax side of it will come together.