Syntax Error: unexpected keyword else, I have gone over it a couple of times!


#1


I don't see the problem, with my code, it keeps saying "unexpected keyword else", any help much appreciated.


var compare = function (choice1, choice2) {
    if (choice1 === choice2) {
        return "The result is a tie!";
    }
    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 win";
    }
}
};


#2

If choice1 is rock who wins :wink:


#3

thank you :confounded:


#4

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