Nodejs Random Number Get randomBetween(min, max)

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

Method Source Code

/**/*from  w w  w  .j  ava2s . co m*/
 * Returns a random number between two values.
 * @param min
 * @param max
 * @returns {number}
 */
Math.randomBetween = function(min, max) {
  return Math.floor(Math.random()*(max-min+1)+min);
};

Related

  1. random(low, high)
    function random(low, high) {
      var rand = (Math.random() * high) + low;
      return rand;
    
  2. random(min, max)
    function random(min, max) {
        return Math.floor(Math.random() * (max - min)) + min;
    
  3. random(min, max)
    function random(min, max) {
       return Math.floor(Math.random() * (max - min + 1)) + min;
    
  4. random(min, max)
    function random(min, max) {
      return Math.floor(Math.random() * max) + min;
    
  5. randomBetween(N, M)
    randomBetween = function(N, M) {
      return Math.floor(M + (1 + N - M) * Math.random());
    };
    
  6. randomGaussian(mean, standardDeviation)
    Math.randomGaussian = function(mean, standardDeviation) {
      if (Math.randomGaussian.nextGaussian !== undefined) {
        var nextGaussian = Math.randomGaussian.nextGaussian;
        delete Math.randomGaussian.nextGaussian;
        return (nextGaussian * standardDeviation) + mean;
      } else {
        var v1, v2, s, multiplier;
        do {
          v1 = 2 * Math.random() - 1; 
    ...
    
  7. GetRandomNum(Min, Max)
    function GetRandomNum(Min, Max) {
      var Range = Max - Min;
      var Rand = Math.random();
      return (Min + Math.round(Rand * Range));
    
  8. getRandomArbitrary(min, max)
    function getRandomArbitrary(min, max) {
        return Math.random() * (max - min) + min;
    
  9. getRandom
    ===