Files
30-seconds-of-code/snippets/random-number-in-range.md
2017-12-12 07:11:37 -05:00

208 B

Random number in range

Use Math.random() to generate a random value, map it to the desired range using multiplication.

const randomInRange = (min, max) => Math.random() * (max - min) + min;