Javascript Math randomInt()

Description

Javascript Math randomInt()


/**//from  www .j a  va 2s  . c  o  m
 * Generates a random integer in the range (0, max-1).
 *
 * @static
 * @method Math.randomInt
 * @param {Number} max The upper boundary (excluded)
 * @return {Number} A random integer
 */
Math.randomInt = function(max) {
    return Math.floor(max * Math.random());
};



PreviousNext

Related