number-operations
JavaScript helper functions for number operations.
Installation
// Install package from npm
npm install @codebundlesbyvik/number-operations
import getRandomIntUnder from "@codebundlesbyvik/number-operations";
Functions
getRandomIntUnder(max, includeMax)
Generate and return a random integer below a given number.
Parameters
* indicates required
-
*
max
(Number
): Depending onincludeMax
, the returned integer will be either equal to or below this number. -
includeMax
(Boolean
): Whether or not to includemax
when generating the integer. Default is undefined, which functions asfalse
.
Usage
getRandomIntUnder(10)
// > 7
getRandomIntUnder(10, true)
// > 10
License
MIT © Viktor Chin-Kon-Sung