Skip to content

randomInt()

randomInt(min, max): number

Defined in: src/utils/mathUtils.ts:13

Generates a random integer between min and max (inclusive).

Parameters

min

number

The minimum value (inclusive).

max

number

The maximum value (inclusive).

Returns

number

A random integer between min and max. Returns NaN if inputs are invalid.

Example

tsx
const random = randomInt(1, 10); // e.g., 7

Released under the MIT License.