## [Solved] Formatting a number with exactly two decimals in JavaScript

To format a number using fixed-point notation, you can simply use the toFixed method: (10.8).toFixed(2); // “10.80” var num = 2.4; alert(num.toFixed(2)); // “2.40” Note that toFixed() returns a string. IMPORTANT: Note that toFixed does not round 90% of the time, it will return the rounded value, but for many cases, it doesn’t work. For … Read more