πΊπΈ 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...
];
const rockPaperScissors = function(num) {
const shot = ["rock", "paper", "scissors"];
// Your CODE
};
// Test
rockPaperScissors();
solution π
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
const rockPaperScissors = function() {
const 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++) {
let temp = [];
temp.push(shot[i], shot[j], shot[k]);
solution.push(temp);
}
}
}
return solution;
};
// Test
console.log(rockPaperScissors());