Here's a random number generator (default and by range)


SUBMITTED BY: antfuentes87

DATE: Nov. 25, 2015, 12:48 a.m.

FORMAT: Text only

SIZE: 257 Bytes

HITS: 748

  1. function randomNumber (num) {
  2. return Math.floor(Math.random() * num)
  3. }
  4. function randomNumberInRange (a,b) {
  5. if (a > b) {
  6. num = randomNumber(a - b)
  7. num += b
  8. }
  9. else {
  10. num = randomNumber(b - a)
  11. num += a
  12. }
  13. return num
  14. }

comments powered by Disqus