Truncate Decimal in JavaScript
Level 129 keystrokes
Math.trunc() removes the fractional part of 5.9 and prints 5.
JavaScript code
// Math.trunc() cuts off the fractional part without rounding: 5.9 becomes 5// Unlike Math.floor(), it moves toward zero: Math.trunc(-5.9) is -51console.log(Math.trunc(5.9));Output
5
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