Build "Rock, Paper, Scissors" number 7


#1

so this is my code

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

    if (choice1 === "paper") {
        if (choice2 === "rock") {
            return "paper wins";
        }
    } else(choice2 === "scissors") {
        return "scissors wins";
    }
}

and right now I 'm only worried about this section bc its the one that wont let me pass:

if (choice1 === "paper") {
    if (choice2 === "rock") {
        return "paper wins";
    }
} else(choice2 === "scissors") {
    return "scissors wins";
}
}

and i looked at a few other forums and they seemed to look like this so what am i doing wrong?


#2

The else should be part of the else if and should belong to the inner if but in your case it is the exception for the else if so that with this statement your condition is finalized and any else ifs coming after this will throw an error. I see that you reacted to this by using ifs instead but this maybe gets rid of the error message but not of the logical problem with it. Think how RPS works and what your cases could look like and maybe have a look at the hint of 6/9


#3

thank you very much !!!!!