random.js 263 B

12345678910
  1. var randomInt = exports.randomInt = function (min, max) {
  2. min = min == null ? 1 : min
  3. max = max == null ? 100 : max
  4. return Math.round(Math.random()*(max - min)) + min
  5. }
  6. exports.randomOf = function (array) {
  7. return array[randomInt(0, array.length - 1)]
  8. }