Ad
Code
Diff
  • function dumbRockPaperScissors(player1, player2) {
    let condition = {
        Scissors: 'Paper',
        Rock: 'Scissors',
        Paper: 'Rock',
      }
    
      if (player2 === condition[player1]) {
        return "Player 1 wins";
      }
    
     if (player1 === condition[player2]) {
        return "Player 2 wins";
      }
        
      if (player1 === player2) {
        return "Draw";
      }
    }
    • 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";
    • let condition = {
    • Scissors: 'Paper',
    • Rock: 'Scissors',
    • Paper: 'Rock',
    • }
    • else if(player1 == "Paper" && player2 == "Scissors"){
    • return "Player 2 wins";
    • }
    • else if(player1 == "Paper" && player2 == "Rock"){
    • if (player2 === condition[player1]) {
    • return "Player 1 wins";
    • }
    • else if(player1 == "Paper" && player2 == "Paper"){
    • return "Draw";
    • }
    • else if(player1 == "Rock" && player2 == "Rock"){
    • return "Draw";
    • if (player1 === condition[player2]) {
    • return "Player 2 wins";
    • }
    • else if(player1 == "Scissors" && player2 == "Scissors"){
    • if (player1 === player2) {
    • return "Draw";
    • }
    • }