Ad

Mixing combinations and math makes it shorter.
But less readable... :)

Code
Diff
  • function dumbRockPaperScissors(player1, player2) {
      const plays = [
        "Rock",
        "Paper",
        "Scissors",
      ];
      const result = plays.indexOf(player1) - plays.indexOf(player2);
      return result === 0 ? 'Draw' : `Player ${[-2, 1].includes(result) ? 1: 2} wins`;
    }
    • function dumbRockPaperScissors(player1, player2) {
    • const plays = [
    • "Rock",
    • "Paper",
    • "Scissors",
    • ];
    • const result = plays.indexOf(player1) - plays.indexOf(player2);
    • return result === 0 ? 'Draw' : `Player ${[-2, 1].includes(result) ? 1: 2} wins`;
    • }