Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. /*
  2. Returns a random integer between 0 and the value sent to the function.
  3. This is not really a new technique but since Math.random() returns a random
  4. float between 0 and 1 we need to increase the range by multipling it by the
  5. biggest value we expect and then "flooring" it, which means it will never
  6. return the max value itself.
  7. */
  8.  
  9. function get_random_number(max) {
  10. return Math.floor(Math.random() * max);
  11. }
  12.  
  13. console.log("Random number ->", get_random_number(25));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement