freeCodeCamp/guide/english/javascript/standard-objects/math/math-random/index.md

24 lines
422 B
Markdown
Raw Normal View History

2018-10-12 19:37:13 +00:00
---
title: Math Random
---
## Math Random
`Math.random()` returns a number between 0 (inclusive) and 1 (exclusive).
#### Syntax
`Math.random()`
#### Example
```js
function randomInRange(min, max) {
return Math.random() * (max - min) + min;
}
```
#### More Information:
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random" target="_blank" rel="nofollow">MDN</a>