Random
Helper functions that have to do with getting random values.
Functions
getRandomInt()
function getRandomInt(
min,
max,
exceptions): number
This returns a random integer between min and max. It is inclusive on both ends.
For example:
const oneTwoOrThree = getRandomInt(1, 3);
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
min | number | undefined | The lower bound for the random number (inclusive). |
max | number | undefined | The upper bound for the random number (inclusive). |
exceptions | readonly number [] | [] | Optional. An array of elements that will be skipped over when getting the random integer. For example, a min of 1, a max of 4, and an exceptions array of [2] would cause the function to return either 1, 3, or 4. Default is an empty array. |
Returns
number