Nodejs Random Number Get randomBetween(N, M)

Here you can find the source of randomBetween(N, M)

Method Source Code

/**/*w  w  w  .  ja v  a  2 s.  c o m*/
 * Returns a random number between N and M
 */
randomBetween = function(N, M) {
   return Math.floor(M + (1 + N - M) * Math.random());
};

Related

  1. random(_minNum,_maxNum,_rejArr)
     function random(_minNum,_maxNum,_rejArr){
         var minNum=_minNum||4,
             maxNum=_maxNum||17,
             rejArr=_rejArr||[],
             num=-1,
             flag=true;
         num = Math.floor(Math.random()*(maxNum-minNum+1)+minNum);
         if(rejArr.length>maxNum-minNum) return -1;
         for(var i=0,len=rejArr.length;i<len;i++){
    ...
    
  2. random(low, high)
    function random(low, high) {
      var rand = (Math.random() * high) + low;
      return rand;
    
  3. random(min, max)
    function random(min, max) {
        return Math.floor(Math.random() * (max - min)) + min;
    
  4. random(min, max)
    function random(min, max) {
       return Math.floor(Math.random() * (max - min + 1)) + min;
    
  5. random(min, max)
    function random(min, max) {
      return Math.floor(Math.random() * max) + min;
    
  6. randomBetween(min, max)
    Math.randomBetween = function(min, max) {
      return Math.floor(Math.random()*(max-min+1)+min);
    };
    
  7. 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; 
    ...
    
  8. GetRandomNum(Min, Max)
    function GetRandomNum(Min, Max) {
      var Range = Max - Min;
      var Rand = Math.random();
      return (Min + Math.round(Rand * Range));
    
  9. getRandomArbitrary(min, max)
    function getRandomArbitrary(min, max) {
        return Math.random() * (max - min) + min;