JavaScript Round a 2 Decimal Places
var subTotal="12.1345";// can also be int, float, string
var subTotalFormatted=parseFloat(subTotal).toFixed(2); //"12.13"
Grepper
var subTotal="12.1345";// can also be int, float, string
var subTotalFormatted=parseFloat(subTotal).toFixed(2); //"12.13"
var number = 12.3456789;
var rounded = Math.round( number * 10 ) / 10;
// rounded is 12.3
>>> parseFloat(0.9999999.toFixed(4));
1
>>> parseFloat(0.0009999999.toFixed(4));
0.001
>>> parseFloat(0.0000009999999.toFixed(4));
0
var num = 125465.33695;
console.log(num.toFixed(2)) //125465.33