Generate repeatable random numbers - Node.js Number

Node.js examples for Number:Random Number

Description

Generate repeatable random numbers

Demo Code


function seededRandom(max, min, seed) {
  var seed = seed || new Date().getTime(),
    rnd;//from  ww  w  . j  ava2 s .c  om
  max = max || 1;
  min = min || 0;

  seed = (seed * 9301 + 49297) % 233280;
  rnd = seed / 233280;

  return min + rnd * (max - min);
}

Related Tutorials