I would like to format my numbers to always display 2 decimal places, rounding where applicable.
Examples:
number display ------ ------- 1
Here's also a generic function that can format to any number of decimal places:
function numberFormat(val, decimalPlaces) { var multiplier = Math.pow(10, decimalPlaces); return (Math.round(val * multiplier) / multiplier).toFixed(decimalPlaces); }