anyof

Generate random number in specific range

Usage no npm install needed!

<script type="module">
  import anyof from 'https://cdn.skypack.dev/anyof';
</script>

README

anyof

Generate random number in specific range

Installation

install via npm

npm install anyof

Usage

anyof(100) //=> generate random number between 0 to 99

Accuracy

Result Distribution

100,000 times range of 0 to 10.

{ 
    '0': 100601,
    '1': 100198,
    '2': 99145,
    '3': 100550,
    '4': 100205,
    '5': 99495,
    '6': 99930,
    '7': 99566,
    '8': 99804,
    '9': 100496 
 }

100,000 times range of 0 to 30.

{ 
  '0': 33476,
  '1': 33422,
  '2': 33446,
  '3': 33637,
  '4': 33317,
  '5': 33201,
  '6': 33513,
  '7': 33393,
  '8': 33418,
  '9': 33478,
  '10': 32965,
  '11': 33188,
  '12': 33586,
  '13': 33023,
  '14': 32978,
  '15': 33472,
  '16': 33625,
  '17': 33213,
  '18': 33176,
  '19': 33458,
  '20': 33329,
  '21': 33254,
  '22': 33452,
  '23': 33116,
  '24': 33451,
  '25': 33242,
  '26': 33525,
  '27': 33248,
  '28': 33390,
  '29': 32978 
}

Test suite

You can test anyof of your own situation with test suite which include in the package.

About Core

anyof is based on Math.random() function

License

MIT