Skip to content

Mint.utils.getRandomInt

Tania Shatilova edited this page Nov 10, 2015 · 1 revision

The getRandomInt() method returns a random number within a specified range.

Syntax

var random = Mint.utils.getRandomInt([min[, max]]);

Parameters

  • min - (int, optional) The inclusive lower bound of the random number returned. Default value is 0.
  • max - (int, optional) The exclusive upper bound of the random number returned. Max must be greater than or equal to min. Default value is Number.MAX_VALUE.

Return Value

A signed integer greater than or equal to min and less or equal than max; that is, the range of return values includes min and max. If min equals max, min is returned.

Examples

Mint.utils.getRandomInt(1, 8);  // 6
Mint.utils.getRandomInt(1);     // 1.794066025907234e+308
Mint.utils.getRandomInt();      // 1.0024528559121937e+308
Mint.utils.getRandomInt("12");  // Error

Clone this wiki locally