Math.random()
Generates a random decimal between 0 and 1.
Syntax
Math.random()
Description
Returns a random number between 0 (inclusive) and 1 (exclusive). Scale for a specific range: Math.floor(Math.random()*n).
Returns
Random decimal (0–1).
Example
Loading editor…
Expected output
true
When to use?
Dice, random selection, games, shuffling.