Return a random number between 0 and 10:
Return a random number between 0 and 100:
A random whole number between 1 and 10:
A random whole number between 1 and 100:
Definition and Usage
Math.random() method returns a random number from 0 (inclusive) up to but not
including 1 (exclusive).
Math.random() does not return a cryptographically secure number.
If you need a cryptographically secure number, use this Crypto API method:
|Number||A random number from 0 (inclusive) up to but not including 1 (exclusive).|
Math.random() is an ECMAScript1 (ES1) feature.