What if choice1 is paper?


#1


https://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/1/3?curriculum_id=506324b3a7dffd00020bf661#

Hi, I tried evertything but I don't know what's wrong with my code. I got a sintax error "Oops, try again. There was a problem with your syntax."

var compare = function(computerChoice, userChoice) {
    if(computerChoice === userChoice) {
        return "The result is a tie!";
    } else if(computerChoice === "rock") {
        if(userChoice === "scissors")
        return "rock wins";
    } else {
        return "paper wins";
    } else if(computerChoice === "paper"){
        if(userChoice === "rock")
        return "paper wins";
    } else {
        return "scissors wins";
    }
}


#2

inside the else if, you should nest a if and a else:

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

but then you shouldn't forget to close else if with a } before moving on to the next else if

then this line:

if(userChoice === "rock")

a { is missing to mark the start of the if block

don't forgot to match the { of the function to close the function

if you need more help, post an updated version of your code


#3

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