Please help with syntax error


#1

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";
    }
}

#2

Two questions.

1) Which lesson are you on (1-9)?

2) what is the full error message you're receiving?


#3

Build rock paper scissors, what if choice1 is paper?
"There was a problem with your syntax"


#4

Correction and explanation :wink:

var compare = function(choice1, choice2) {
if(choice1 === choice2) {
return "The result is a tie!";
}
else if(choice1 === "rock") {
//you shouldn t close your } here, this else if needs to wrap the if and else statement //that follow before closing and jumping to the other else if
if(choice2 === "scissors") {
return "rock wins";
}
else {
return "paper wins";
}
} // close the first else if
else if(choice1 === "paper") {
//don t close
if(choice2 === "rock") {
return "paper wins";
}
else {
return "scissors wins";
}
}
}; // close the function


#5

Thank you for your help!


#6

you're very welcome, glad it helps :smile: