What if choice 1 is scissors


#1

What is wrong? please help! I get: SyntaxError: expected expression, got keyword 'else'

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";
}
else if (choice1 === "paper") {
if (choice2 === "rock") {
return "paper wins";
}
else {
return "scissors wins";
}
else if (choice1 === "scissors") {
if (choice2 === "rock") {
return "rock wins";
}
else {
return "scissors wins";
}
}
}
compare (userChoice, computerChoice)


#2

Your first and second else if statement's are not closed, you need to close it after else.


#3

Thank you, I've closed them but there is still something wrong because I got: ReferenceError: userChoice is not defined

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";
    }  
    }  
    else if (choice1 === "paper") {
        if (choice2 === "rock") {
            return "paper wins";
    }
        else {
            return "scissors wins";
    }
    } 
    else if (choice1 === "scissors") {
        if (choice2 === "rock") {
            return "rock wins";
    }   
        else {
            return "scissors wins";
            }
        }
      }   
compare (userChoice, computerChoice)

#4

2.We need to use the variables userChoice and computerChoice. Uncomment the first lines of the code by deleting /* on line 1 and */ on line 9, the variables are now active and can be called.

Where's this bit of code, did you uncomment it ?

  1. Call your function and pass in userChoice and computerChoice as your two arguments.

You need to change from choice1, choice2

This :arrow_down: needs to be console.log(userChoice, computerChoice);


#5

Thanks a lot for your help!