Aggregate
is a general aggregator over a data set that passes pairs of first and immediately next element of the data set to a lambda function and returns the cumulative result of lambda expression.
var totalSize = pencils.reduce((previous, current) => { return previous.size + current.size; });