Skip to content

Random

Helpers for working with randomness, various functions for random numbers and other values.

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
const value = api.random.randomNumber(5.5 /* min */, 50 /* max */);
console.log(value) // 5.5 - 50

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
const value = api.random.randomInteger(5 /* min */, 50 /* max */);
console.log(value) // 5 - 50

Function () => boolean

Randomly returns either true or false

const value = api.random.randomBoolean();
console.log(value) // true / false

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
const items = [
"test",
"test2",
"test3"
];
const value = api.random.randomArrayItem(items);
console.log(value) // test / test2 / test3