utils.js 381 B

123456789101112131415161718
  1. function randomInt (min, max) {
  2. return min + Math.round(Math.random() * max);
  3. }
  4. function getRandomArrayValue (source) {
  5. const randomIndex = randomInt(0, source.length - 1);
  6. return source[randomIndex];
  7. }
  8. function capitalize (str) {
  9. return str && str[0].toUpperCase() + str.substr(1);
  10. }
  11. module.exports = {
  12. randomInt,
  13. getRandomArrayValue,
  14. capitalize
  15. };