84
JavaScript Math random() method
The JavaScript math random() method returns the random number between 0 (inclusive) and 1 (exclusive).
Syntax
The random() method is represented by the following syntax:
Return
The random number between 0 (inclusive) and 1 (exclusive).
JavaScript Math random() method example
Here, we will understand random() method through various examples.
Example 1
Let’s see an example to find out the random number between 0 and 1.
Output:
0.9118351487222218
Example 2
Let’s see an example to find out the random number between two values.
Output:
3.9030538241130746
Example 3
Let’s see an example to find out the random integer number between two values.
Output:
3
Next TopicJavaScript Math