All files / lib/helpers numbers.js

100% Statements 20/20
92.86% Branches 13/14
100% Functions 4/4
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32  21x 7x     1x 1x 1x     1x     8x 4x 4x 1x   3x     1x 1x                  
 
const randomBetween = ([min, max]) => {
  return Math.floor(Math.random()*(max-min+1)+min)
}
 
var randomArray = function randomElementInArray(arr) {
  const ele = Math.floor(Math.random()*(arr.length - 1))
  return arr[ele];
}
 
const randomBetweenWithString = (value, {
  prefix = '',
  suffix = ''
} = {}) => {
  const randomNumber = randomBetween(value)
  if (!prefix && !suffix) {
    return `${randomNumber}`
  }
  return `${prefix}${randomNumber}${suffix}`
}
 
const incrementNumber = (value, { index, from = 0 }) => {
  return from + index
}
 
export {
  incrementNumber,
  randomBetween,
  randomArray,
  randomBetweenWithString,
}