Ad
Code
Diff
  • function rps(p1, p2) {
      let arr = ['rock','paper','scissors']
      return p1 == p2 ? 'Draw!' : 
        p1 == arr[0] && p2 == arr[2] || 
        p1 == arr[2] && p2 == arr[1] || 
        p1 == arr[1] && p2 == arr[0] ? 'Player 1 won!' : 'Player 2 won!';
    }
    
    • function rps(player1, player2) {
    • return player1 == player2 ? 'Draw!' :
    • player1 == 'rock' && player2 == 'scissors' ||
    • player1 == 'scissors' && player2 == 'paper' ||
    • player1 == 'paper' && player2 == 'rock' ? 'Player 1 won!' : 'Player 2 won!';
    • function rps(p1, p2) {
    • let arr = ['rock','paper','scissors']
    • return p1 == p2 ? 'Draw!' :
    • p1 == arr[0] && p2 == arr[2] ||
    • p1 == arr[2] && p2 == arr[1] ||
    • p1 == arr[1] && p2 == arr[0] ? 'Player 1 won!' : 'Player 2 won!';
    • }