randomOrElse
randomOrElse(array, callback)
Returns a random element from array
, or the result of calling callback
with the array if the array is empty.
ts
randomOrElse([1, 2, 3, 4], (arr) => arr.length); // 2 (random)
ts
pipe(
[1, 2, 3, 4],
randomOrElse((arr) => arr.length),
); // 2 (random)