What if choice 1 is rock?


#1

Hello. I've been trying to write this code for hours and I even copied code from hint but it shows error.

The code is:

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

}


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

With the second } you end the function so the else is outside of it where it is pretty unexpected.