JAVASCRIPT   11

rand.js

Guest on 23rd August 2021 04:49:31 PM

  1. /**<dependency>[rand]</dependency>**/
  2. function rand (min, max) {
  3.  
  4.   var argc = arguments.length;
  5.   if (argc === 0) {
  6.     min = 0;
  7.     max = 2147483647
  8.   } else if (argc === 1) {
  9.     throw new Error('Warning: rand() expects exactly 2 parameters, 1 given');
  10.   }
  11.   return Math.floor(Math.random() * (max - min + 1)) + min;
  12. };

Raw Paste


Login or Register to edit or fork this paste. It's free.