12345678910111213141516171819202122 |
- function randomInt (min, max) {
- return min + Math.round(Math.random() * max);
- }
- function getRandomArrayValue (source) {
- if (!(source && source.length)) {
- return;
- }
- const randomIndex = randomInt(0, source.length - 1);
- return source[randomIndex];
- }
- function capitalize (str) {
- return str && str[0].toUpperCase() + str.substr(1);
- }
- module.exports = {
- randomInt,
- getRandomArrayValue,
- capitalize
- };
|