random.js 205 B

12345678910
  1. function random(min, max) {
  2. if (min >= 0 && max > 0 && max >= min) {
  3. let gab = max - min + 1;
  4. return Math.floor(Math.random() * gab + min);
  5. } else {
  6. return 0;
  7. }
  8. }
  9. export default random;