Rock, Paper, Scissors in JavaScript

You were unable to see the issue most likely due to poor indentation of your code. Properly indented the issue is clear:

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

Your if (choice1 === "scissors") { is within if (choice1 === "paper") {. The code within will never be reached.

Leave a Comment