Math.random Last updated: 30. May 2026
Returns a number, decimal between 0 and 1.
See also: Math.floor Math.round Math.ceil
Parameters
This function takes no parameters
Returns
A floating-point number between 0 (inclusive) and 1 (exclusive).
Example
Code example (#JS)
#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.#Math.round(Math.random() * 100)# Output
The #JS code above produces the output shown below:27