es6 sum all numbers in array code example
Example 1: typescript sum all array values
const sum = receiptItems.reduce((sum, current) => sum + current.total, 0);
Example 2: sum all elements in array javascript
arr.reduce((a, b) => a + b)
const sum = receiptItems.reduce((sum, current) => sum + current.total, 0);
arr.reduce((a, b) => a + b)