Node.js examples for Array:Array Value
Original array with rounded values
/**/*from w ww .j ava 2s. c o m*/ * * @param {Number} decimalPlaces * number of decimal places * * @return {Array} original array with rounded values * */ Array.prototype.round = function(decimalPlaces) { var multi = Math.pow(10,decimalPlaces); for (var i=0; i<this.length; i++) this[i] = Math.round(this[i] * multi)/multi; return this; };