round to nearest 2 decimal places javascript code example
Example 1: rounding number to x decimals javascript
let num = 12.5452411;
num = num.toFixed(3); // 12.545
Example 2: get decimals from float javascript
js> 2.3 % 1
0.2999999999999998
let num = 12.5452411;
num = num.toFixed(3); // 12.545
js> 2.3 % 1
0.2999999999999998