🎱randomArray

Retorna um ou mais itens aleatoriamente de uma array

Tipos:

Parâmetros:

  1. input: array

Retorno:

Exemplos de uso:

const { randomArray } = require("util-stunks");

const example = ["Laura", "Lucas", "Sofia", "Mateus", "Isabela"];

randomArray(example); // ["Lucas"]
randomArray(example); // ["Mateus"]

randomArray(example, { quantity: 2 }); // ["Isabela", "Mateus"]
randomArray(example, { quantity: 4 }); // ["Sofia", "Isabela", "Mateus", "Sofia"]

randomArray(example, { quantity: 4, removeSelectItem: true }) // ["Matues", "Lucas", "Laura", "Isabela"]
randomArray(example, { quantiy: 3, removeSelectItem: true }) // ["Isabela", "Sofia", "Matues"]

Last updated