2.6 "Syntax Error: Unexpected number"...of all of unexpected things!


#1

Has anyone else worked through a similar issue? After reviewing the other posts on this section I'm still not sure how exactly I went wrong...

I appreciate any help you can give :slightly_smiling:

var compare = function (choice1, choice2){
if (choice1 === choice2){
return "The result is a tie!";
}

else if(choice 1 === "rock"){

if (choice 2 === "scissors"){
return "rock wins";
}
else {
return "paper wins";
}
}


#2

You should close your compare function like that. ..

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";
}
} <== this one the else if statement 
} <== this one close the compare function

#3

Thanks for spotting that!

I'm now getting a "Oops, try again. There was a problem with your syntax" after trying to run the updated version. Any other ideas?

var compare = function (choice1, choice2){
if (choice1 === choice2){
return "The result is a tie!";
}

else if(choice 1 === "rock"){

if (choice 2 === "scissors"){
return "rock wins";
}
else {
return "paper wins";
}
}
}


#4

Try to remove the space between choice and 1 also choice and 2