randomInt
function randomInt(options: RandomIntOptions = {}): number;
The randomInt
function can be used to to generate a random
integer between a min and max value.
Math.random does not provide cryptographically secure random numbers. Do not use them for anything related to security.
Example Usage
randomInt(); // an integer between 0 and 10
randomInt({ min: -100, max: 100 }); // an integer between -100 and 100
Parameters
options
(optional) - an object with the following definition:
export interface RandomIntOptions {
/** @defaultValue `0` */
min?: number;
/** @defaultValue `10` */
max?: number;
}
Returns
A random integer.