Skip to content

Commit

Permalink
getElement function
Browse files Browse the repository at this point in the history
  • Loading branch information
mankal111 committed Oct 15, 2018
1 parent 9852032 commit 1862447
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,19 @@ function getInterval(options) {
return [leftEndpoint, rightEndpoint];
}

/**
* Returns a random element from given array
* @param {array} array - The array
* @returns The random element
*/
function getRandomElement(array) {
return array[getNumber({ min: 0, max: array.length - 1, type: 'integer' })];
}

const JXRand = {
getNumber,
getInterval,
getRandomElement,
};

module.exports = JXRand;

0 comments on commit 1862447

Please sign in to comment.