Calculate array average - Node.js Array

Node.js examples for Array:Array Operation

Description

Calculate array average

Demo Code


if (typeof Array.prototype.average != 'function') {
  Array.prototype.average = function() {
    return this.sum() / this.length;
  };//from w  w  w.j av  a 2  s.  com
}

Related Tutorials