All files / lib/helpers numbers.js

92.86% Statements 13/14
87.5% Branches 7/8
100% Functions 3/3
90.91% Lines 10/11

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  21x 7x     1x 1x 1x     1x     8x 4x 4x     4x                
 
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)
  Iif (!prefix && !suffix) {
    return `${randomNumber}`
  }
  return `${prefix}${randomNumber}${suffix}`
}
 
export {
  randomBetween,
  randomArray,
  randomBetweenWithString,
}