Random
Helpers for working with randomness, various functions for random numbers and other values.
randomNumber
Function (min: number, max: number) => number
Returns a random number between the provided min
(minimum) and max
(maximum) values.
Number may include a decimal value, use randomInteger to only get whole numbers
Argument | Type | Example | Description |
---|---|---|---|
min | number | 5.5 | The minimum possible number allowed |
max | number | 50 | The maximum possible number allowed |
randomInteger
Function (min: number, max: number) => number
Returns a random number between the provided min
(minimum) and max
(maximum) values.
Argument | Type | Example | Description |
---|---|---|---|
min | number | 5 | The minimum possible number allowed |
max | number | 50 | The maximum possible number allowed |
randomBoolean
Function () => boolean
Randomly returns either true
or false
randomArrayItem
Function <T>(array: T[]) => T
Picks a random item from the provided array
Argument | Type | Example | Description |
---|---|---|---|
array | array | [ "test", "test2", "test3"] | The list of values to pick from |