freeCodeCamp/guide/english/javascript/standard-objects/math/math-random/index.md

422 B

title
Math Random

Math Random

Math.random() returns a number between 0 (inclusive) and 1 (exclusive).

Syntax

Math.random()

Example

function randomInRange(min, max) {
  return Math.random() * (max - min) + min;
}

More Information:

MDN