5. Both choices are the same!



I'm having trouble with this piece of code, I am sure it is written correctly but every time I make amendments it still provides me with the same error message: "SyntaxError: Unexpected token"

I didn't need the ";" after function(choice1, choice2);

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


Hello there, you have an extra semicolon after "function(choice1, choice2)" which shouldnt be there.


Hi, do you know what is wrong with my 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";
return "paper wins";


you have an extra curly brackets after "the result is a tie!"
and you have to open a curly bracket after the end of the parameter of else if
heres my 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";


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