cachaito
12/26/2014 - 4:59 PM

Generate random numbers

// @return [float] a random number between min and max
function getRandom(min, max) {
  return Math.random() * (max - min) + min;
}

// @return [integer] a random int between min and max
function getRandomInt(min, max) {
  return Math.floor(Math.random() * (max - min)) + min;
}

// simpler
Math.floor(Math.random()*max);

// Lodash
_.random(15, 20);