Random Number in JavaScript

Level 127 keystrokes

Math.random() returns a random decimal from 0 (inclusive) up to 1 (exclusive), so the output changes on every run.

JavaScript code

// Math.random() returns a decimal in the range 0 <= x < 1
// Each call gives a different value, so the printed number varies
1console.log(Math.random());

Output

0.7234567890123456
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this JavaScript code and how often they appear.

  • .× 2
  • (× 2
  • )× 2
  • ;× 1

More JavaScript examples at level 1

← JavaScript typing practice