It will iterate through each of the provided values array and add the value of each element's property, then divide by values.lengthto produce the desired mean.
values
property
values.length
mean
1.0.0
meanByProperty([{ a: 1 }, { a: 2 }, { a: 3 }], "a"); // => 2 Copy
meanByProperty([{ a: 1 }, { a: 2 }, { a: 3 }], "a"); // => 2
It will iterate through each of the provided
values
array and add the value of each element'sproperty
, then divide byvalues.length
to produce the desiredmean
.