Skip to main content

functions/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

ParameterTypeDefault valueDescription
minnumberundefinedThe lower bound for the random number (inclusive).
maxnumberundefinedThe upper bound for the random number (inclusive).
exceptionsreadonly 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

Defined in

functions/random.ts:25