Fix: average() API plug-in was one short in its data count.

pull/65/head
Allan Jardine 11 years ago
parent a6276c14ab
commit b644af9c80

@ -22,12 +22,11 @@
*/
jQuery.fn.dataTable.Api.register( 'average()', function () {
var i=0;
var sum = this.flatten().reduce( function ( a, b ) {
i++;
return (a*1) + (b*1); // cast values in-case they are strings
} );
return sum / i;
var data = this.flatten();
var sum = data.reduce( function ( a, b ) {
return (a*1) + (b*1); // cast values in-case they are strings
} );
return sum / data.length;
} );

Loading…
Cancel
Save