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

8 lines
208 B
Markdown

### Random number in range
Use `Math.random()` to generate a random value, map it to the desired range using multiplication.
```js
const randomInRange = (min, max) => Math.random() * (max - min) + min;
```