Skip to content

Function: randomInt()

ts
function randomInt(min, max): number;

Generates a random integer between min and max (inclusive). 生成指定范围内的随机整数(包含边界)。

Parameters

ParameterTypeDescription
minnumberThe minimum value (inclusive) / 最小值(包含)
maxnumberThe maximum value (inclusive) / 最大值(包含)

Returns

number

A random integer / 随机整数

Example

typescript
randomInt(1, 10) // => a number between 1 and 10
randomInt(0, 100) // => a number between 0 and 100
randomInt(-5, 5) // => a number between -5 and 5

Since

1.0.0

Released under the MIT License.