randomjs-lib
v0.1.0
Published
A JS lib to generate random numbers
Downloads
2
Maintainers
Readme
randomjs-lib
A lib to get random numbers, booleans and elements from an array.
How to install
yarn add randomjs-lib
npm install --save randomjs-lib
Features:
- Randomize an integer:
const random = require('randomjs-lib')
random.randInt(begin, end);
// eg: random.randInt(1, 10)
// eg result: 8
- Randomize a float:
const random = require('randomjs-lib')
random.randFloat(begin, end, decimal_places);
// eg: random.randFloat(1.5, 2, 2)
// eg result: 1.67
- Randomize a boolean:
const random = require('randomjs-lib')
random.randBoolean();
// eg result: true
- Randomize an even number
const random = require('randomjs-lib')
random.randEven(begin, end);
// eg: random.randEven(1, 10)
// eg result: 2
- Randomize an odd number
const random = require('randomjs-lib')
random.randOdd(begin, end);
// eg: random.randEven(1, 10)
// eg result: 7
- Randomize an element from an array
const random = require('randomjs-lib')
random.randElement(Array);
// eg: random.randEven([1, 10, 28, 34])
// eg result: 28