export interface data {
id: number;
cost: number;
}
array: data[] = [
{ id: 1, cost: 25 },
{ id: 2, cost: 25 },
{ id: 3, cost: 50 },
{ id: 4, cost: 200 },
{ id: 5, cost: 10 },
{ id: 6, cost: 60 },
];
result: number = arr.reduce((accumulator, obj) => {
return accumulator + obj.cost;
}, 0);