Posted By

jrobinsonc on 02/25/12


Tagged


Versions (?)

Generate random integer


 / Published in: JavaScript
 

Usage: random_integer(1,100);

  1. /*
  2.   Receives the lowest and highest values of a range and
  3.   returns a random integer that falls within that range.
  4. */
  5. function random_integer(low, high)
  6. {
  7. return low + Math.floor(Math.random() * (high - low));
  8. }

Report this snippet  

You need to login to post a comment.