Floor Function in JavaScript

Level 129 keystrokes

Uses Math.floor() to round 3.7 down and prints 3.

JavaScript code

// Math.floor() returns the largest integer less than or equal to the number
// 3.7 becomes 3; for negatives it goes down too: Math.floor(-3.7) is -4
1console.log(Math.floor(3.7));

Output

3
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.

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

More JavaScript examples at level 1

← JavaScript typing practice