Nodejs Random Int Number Get getRandomInt(min, max)

Here you can find the source of getRandomInt(min, max)

Method Source Code

/**/*w  w w. ja v a 2s  .  co m*/
 * Return a int in the interval [min ; max[
 * @param min
 * @param max
 * @returns {number}
 */
function getRandomInt(min, max)
{
    return Math.floor(Math.random() * (max - min) + min);
}

Related

  1. getRandomInt (min, max)
    function getRandomInt (min, max) {
        return Math.floor(Math.random() * (max - min + 1)) + min;
    
  2. getRandomInt(min, max)
    function getRandomInt(min, max) {
      return Math.floor(Math.random() * (max - min)) + min;
    Array.prototype.max = function( array ){
        return Math.max.apply( Math, array );
    };
    
  3. getRandomInt(min, max)
    function getRandomInt(min, max) {
      return Math.floor(Math.random() * (max - min)) + min;
    
  4. getRandomIntInclusive(min, max)
    Random.getRandomIntInclusive(min, max){
        return Math.floor(Math.random() * (max - min + 1) + min);
    
  5. randomInt(a,b)
    Math.randomInt = function(a,b){ 
      var min = Math.min(a,b);
      var max = Math.max(a,b)+1;
      var delta = max-min;
      return Math.floor(min + (Math.random()*delta));