function round(num, decimalPlaces) {
n = Math.pow(10, decimalPlaces);
return Math.round(num * n) / n;
}

Adventures in Computer Programming – bakert@gmail.com
function round(num, decimalPlaces) {
n = Math.pow(10, decimalPlaces);
return Math.round(num * n) / n;
}