Returns a random element of an array
const v = [`blue`, `red`, `orange`];randomElement(v); // Yields `blue`, `red` or `orange` Copy
const v = [`blue`, `red`, `orange`];randomElement(v); // Yields `blue`, `red` or `orange`
Note that repeated calls might yield the same value multiple times. If you want to random unique values, consider using shuffle.
See also:
Random generator. Math.random by default.
Math.random
Returns a random element of an array
Note that repeated calls might yield the same value multiple times. If you want to random unique values, consider using shuffle.
See also: