7. (choice1 === paper) syntax error


#1

SyntaxError: expected expression, got keyword 'else'. Whats wrong?

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 "rock wins" }
        } else {
        return "scissors wins"}
}

#2

You close your else if too early:

 else if (choice1 === "rock") { // opens else if
        if (choice2 === "scissors") { // opens if
        return "rock wins" } // closes if
        } else { // closes else if , opens else
        return "paper wins"}      // closes else
    else if // unexpected else (if)

The else should be inside of the else if as well.


8 missing before statement
#3
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"}      
    }

}

Thanks. Now it works fine.