randomInt es-toolkit
Generates a random integer within a specified range.
Usage
randomInt(maximum) / randomInt(minimum, maximum)
Use randomInt when you need a random integer. It returns only integers without decimal points.
Parameters
maximumnumberrequired
The maximum value (exclusive) when using a single parameter. Must be greater than 0.
minimumnumberrequired
The minimum value (inclusive).
maximumnumberrequired
The maximum value (exclusive). Must be greater than the minimum value.
Returns
Returns a random integer within the specified range.
Throws
Throws an error if the maximum value is less than or equal to the minimum value.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.