Skip to content

compute prod

kgryte edited this page May 12, 2015 · 1 revision

Computes the product of an array.

var data = [ 2, 4, 2, 7, 3 ];

var prod = compute.prod( data );
// returns 336

For object arrays, provide an accessor function for accessing array values

var data = [
	{'x':2},
	{'x':1},
	{'x':3}
];

function getValue( d ) {
	return d.x;
}

var prod = compute.prod( data, getValue );
// returns 6
Clone this wiki locally