Fixed Decimal Places in JavaScript
Level 134 keystrokes
toFixed(2) formats 3.14159 with two decimal places and prints "3.14".
JavaScript code
// The parentheses make the method call on the number literal clear (5.toFixed(2) would be a syntax error)// toFixed(2) rounds to 2 decimal places and returns a string, "3.14"1console.log((3.14159).toFixed(2));Output
3.14
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(× 3)× 3;× 1