Ad
Code
Diff
  • 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";
      }
    
    }
    • 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";
    • }
    • }
Code
Diff
  • const firstNonRepeatingCharacter = (str) => {
      console.log("haha");
        for (let i = 0; i < str.length; i++) {
            let seenDuplicate = false;
            for (let j = 0; j < str.length; j++) {
                if (str[i] === str[j] && i !== j) {
                    seenDuplicate = true;
                    break;
                }
            }
            if (!seenDuplicate) {
                return str[i];
            }
        }
        return null; // return null if no unique character is found
    };
    • const firstNonRepeatingCharacter = (str) => {
    • console.log("haha");
    • for (let i = 0; i < str.length; i++) {
    • let seenDuplicate = false;
    • for (let j = 0; j < str.length; j++) {
    • if (str[i] === str[j] && i !== j) {
    • seenDuplicate = true;
    • break;
    • }
    • }
    • if (!seenDuplicate) {
    • return str[i];
    • }
    • }
    • return null; // return null if no unique character is found
    • };