js round any number to 2 decimals only if needed code example
Example: javascript round to 2 decimal places
var subTotal="12.1345";// can also be int, float, string
var subTotalFormatted=parseFloat(subTotal).toFixed(2); //"12.13"
var subTotal="12.1345";// can also be int, float, string
var subTotalFormatted=parseFloat(subTotal).toFixed(2); //"12.13"