Skip to content

random

Array.random(array)

Returns a random element from array, or undefined if the array is empty.

Example

ts
import { Array } from "@monstermann/array";

Array.random([1, 2, 3, 4]); // 2 (random)
ts
import { Array } from "@monstermann/array";

pipe([1, 2, 3, 4], Array.random()); // 2 (random)