Closed joente closed 1 year ago
Add function sum (sum all elements of a list).
sum
Similar behavior could be achieved using the reduce function but this is more difficult to read.
Example:
range(10).reduce(|i, t| i+ t, 0); // 45 // versus range(10).sum(); // 45
Another example with callback:
[{x: 1, x: 2}].reduce(|o, t| t + o.x, 0); // 3 // versus [{x: 1, x: 2}].sum(|o| o.x); // 3
Please delete options that are not relevant.
Description
Add function
sum
(sum all elements of a list).Similar behavior could be achieved using the reduce function but this is more difficult to read.
Example:
Another example with callback:
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Checklist: