Ad
Code
Diff
  • function dumbRockPaperScissors(player1, player2) {
      const OBJECTS = ['Rock', 'Paper', 'Scissors'];
      return player1 === OBJECTS[0] && player2=== OBJECTS[0] || 
        player1 === OBJECTS[1] && player2=== OBJECTS[1] ||
        player1 === OBJECTS[2] && player2=== OBJECTS[2] ? 'Draw' :
        player1=== OBJECTS[0] && player2=== OBJECTS[1] ||
        player1=== OBJECTS[1] && player2=== OBJECTS[2] ||
        player1=== OBJECTS[2]  && player2=== OBJECTS[0]  ? 'Player 2 wins' :
        'Player 1 wins';
    
    }
    • function dumbRockPaperScissors(player1, player2) {
    • if(player1 == "Rock" && player2 == "Paper"){
    • return "Player 2 wins";
    • }
    • else if(player1 == "Rock" && player2 == "Scissors" ){
    • return "Player 1 wins";
    • }
    • else if(player1 == "Scissors" && player2 == "Paper"){
    • return "Player 1 wins";
    • }
    • else if(player1 == "Scissors" && player2 == "Rock"){
    • return "Player 2 wins";
    • }
    • else if(player1 == "Paper" && player2 == "Scissors"){
    • return "Player 2 wins";
    • }
    • else if(player1 == "Paper" && player2 == "Rock"){
    • return "Player 1 wins";
    • }
    • else if(player1 == "Paper" && player2 == "Paper"){
    • return "Draw";
    • }
    • else if(player1 == "Rock" && player2 == "Rock"){
    • return "Draw";
    • }
    • else if(player1 == "Scissors" && player2 == "Scissors"){
    • return "Draw";
    • }
    • const OBJECTS = ['Rock', 'Paper', 'Scissors'];
    • return player1 === OBJECTS[0] && player2=== OBJECTS[0] ||
    • player1 === OBJECTS[1] && player2=== OBJECTS[1] ||
    • player1 === OBJECTS[2] && player2=== OBJECTS[2] ? 'Draw' :
    • player1=== OBJECTS[0] && player2=== OBJECTS[1] ||
    • player1=== OBJECTS[1] && player2=== OBJECTS[2] ||
    • player1=== OBJECTS[2] && player2=== OBJECTS[0] ? 'Player 2 wins' :
    • 'Player 1 wins';
    • }