Skip to main content

Function: pickRandom()

pickRandom(array, amount)

pickRandom<T>(array: readonly T[], amount?: 1): T

Picks a random element from an array

Type parameters

Type parameter
T

Parameters

ParameterTypeDescription
arrayreadonly T[]The array to pick a random element from
amount?1Amount of values to obtain randomly (default: 1)

Returns

T

Source

lib/pickRandom.ts:6

pickRandom(array, amount)

pickRandom<T>(array: readonly T[], amount: number): T[]

Type parameters

Type parameter
T

Parameters

ParameterType
arrayreadonly T[]
amountnumber

Returns

T[]

Source

lib/pickRandom.ts:7