Skip to content

Instantly share code, notes, and snippets.

@brumm
Created August 25, 2016 10:58
Show Gist options
  • Save brumm/f6dbb030fab56f33d95a22edcf383135 to your computer and use it in GitHub Desktop.
Save brumm/f6dbb030fab56f33d95a22edcf383135 to your computer and use it in GitHub Desktop.
untitled
import random from 'number-random'
const hour = 1000 * 60 * 60
const range = random(hour * 4, hour * 7)
const chunkNum = random(1, 4)
let chunks = Array.from({ length: chunkNum })
.map((item, index) => (
Math.random()
))
const sum = chunks.reduce(
(accumulator, chunk) => accumulator + chunk
)
chunks = chunks.map(chunk => {
let value = Math.round(((chunk / sum) * range) * 4) / 4.0
return value
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment