๐Ÿ‡บ๐Ÿ‡ธ Complete the function that generates every possible sequence of shoots that a player could shot. [ rock / paper / scissors ]

๐Ÿ‡ฆ๐Ÿ‡ท Completa la funcion que genere todas las secuencias posibles de tiros que un jugador pueda tirar. [ piedra / papel / tijera ] (traducido)

๐Ÿ‡ฐ๐Ÿ‡ท ๋„์ „์ž๊ฐ€ ๋˜์งˆ ์ˆ˜ ์žˆ๋Š” ๋ชจ๋“  ๊ฒฝ์šฐ์˜ ์ˆ˜๋ฅผ ์ƒ์‚ฐํ•˜๋Š” ํ•จ์ˆ˜์˜ ๊ธฐ๋Šฅ์„ ์™„๋ฃŒํ•˜์„ธ์š”. [ ๊ฐ€์œ„ / ๋ฐ”์œ„ / ๋ณด ] (๋ฒˆ์—ญ)

Example:

Your output should look something like:

// Test
rockPaperScissors();

// Output -> Array of arrays
// All the posible shots
[
  ["rock", "rock", "rock"],
  ["rock", "rock", "paper"],
  ["rock", "rock", "scissors"],
  ["rock", "paper", "rock"]
  //    ...etc...
];

# START [ here ] ๐Ÿ

var rockPaperScissors = function(num) {
  var shot = ["rock", "paper", "scissors"];
  // Your CODE
};

// Test
rockPaperScissors();

# Javascript solution ๐Ÿ†

  • Run it on your browser console window (F12) ๐Ÿ–ฅ
  • Feel free to COMMENT your preference language solution ๐Ÿ‘ฉโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ
  • Do your best to complete the problem ๐ŸŽญ
  • if you can't beat this the solution is below ๐Ÿ˜ฑ

solution ๐Ÿ‘‡

.
.
.
.
.
.
.
.
.
.
.

var rockPaperScissors = function() {
  var shot = ["rock", "paper", "scissors"];
  // Your CODE
  let solution = [];

  for (let i = 0; i < shot.length; i++) {
    for (let j = 0; j < shot.length; j++) {
      for (let k = 0; k < shot.length; k++) {
        var temp = [];
        temp.push(shot[i], shot[j], shot[k]);
        solution.push(temp);
      }
    }
  }
    return solution;
};

// Test
console.log(rockPaperScissors());