24 lines
422 B
Markdown
24 lines
422 B
Markdown
|
---
|
||
|
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>
|
||
|
|
||
|
|