1Math.round(X); // round X to an integer
2Math.round(10*X)/10; // round X to tenths
3Math.round(100*X)/100; // round X to hundredths
4Math.round(1000*X)/1000; // round X to thousandths
1function round(value, precision) {
2 var multiplier = Math.pow(10, precision || 0);
3 return Math.round(value * multiplier) / multiplier;
4}