limit float decimal javascript code example
Example 1: js number with four decimal places
var myNumber = 2;
myNumber.toFixed(2); //returns "2.00"
myNumber.toFixed(1); //returns "2.0"
Example 2: rounding number to x decimals javascript
let num = 12.5452411;
num = num.toFixed(3); // 12.545
Example 3: coffeescript float to two decimal places
number = 24.54616515.toFixed 2 #24.55