rand-paul
v2.1.2
Published
Get a random value from an array
Downloads
4
Readme
Rand Paul
Get a random value from an array.
Usage
npm install rand-paul --save
var rand = require('rand-paul');
var candidates = [
'Ted Cruz',
'Ben Carson',
'Jeb Bush',
'Mike Huckabee',
'Rand Paul',
'Donald Trump'
]
var president = rand.paul(candidates);
console.log(president) // => 'Rand Paul'
You can grab the index of the item by specifying it in the options object.
var president = rand.paul(candidates, {includeIndex: true});
console.log(president) // => { item: 'Rand Paul', includeIndex: 4 }
Contribution
Fork and do your thing. If your code is as messy and/or unkempt as Rand's hair I will not accept.
LICENSE
WTFPL (...)