random.js 233 B

12345678910
  1. // Return a random integer between `min` and `max` (inclusive).
  2. function random(min, max) {
  3. if (max == null) {
  4. max = min;
  5. min = 0;
  6. }
  7. return min + Math.floor(Math.random() * (max - min + 1));
  8. }
  9. module.exports = random;