JS Built-ins
← Math174 / 215
Mathrandomintermediate

Math.random() β€” Always a Number Type

πŸ“– Usage Example
// Pseudo-random float in [0, 1)
Math.random()                        // β†’ e.g. 0.7421...
Math.floor(Math.random() * 6)        // β†’ 0–5

Use Math.random() to generate a pseudo-random floating-point number between 0 (inclusive) and 1 (exclusive).

Math.random()

Returns a pseudo-random floating-point number in the range [0, 1).

Challenge: Confirm that every call to Math.random() returns a value of type 'number'.

πŸ’‘ Hints (1)
  • β€’ Math.random() consistently returns a number primitive