REDUCE
Returns a value resulting from applying a formula to each element of the array and the previous result.
Syntax
=REDUCE(initialValue, array, expression)
Arguments
Argument | Type | Description |
---|---|---|
initialValue | Any | Initial value for the previous result |
array | Array | Array of elements |
expression | Lambda | Transformation to perform on each item of the array |
Examples
=REDUCE(0, [10, 20, 30], x => x + x.previous)
→60
REDUCE
function is called for each item in the array (the values 10, 20, and 30). For each item, the value is added to the previous result. The last result is returned for the function, resulting in the value 60.
Updated 10 months ago