typescript sum array of objects code example
Example 1: typescript sum all array values
const sum = receiptItems.reduce((sum, current) => sum + current.total, 0);
Example 2: javascript sum array of objects
arr = [{x:1}, {x:3}]
arr.reduce((accumulator, current) => accumulator + current.x, 0);