I would be glad if anyone could explain to me why when I want to get a sum of amounts I always get an error something like: "Operator + cannot be applied to types '{ data: string, amount: number}' or any other type.
const payments = [
[
{ data: '11/12/19', amount: 1000 },
],
[
{ data: '11/01/20', amount: 1000 },
{ data: '12/01/19', amount: 1000 },
],
[],
[
{ data: '11/02/20', amount: 1000 },
{ data: '12/02/19', amount: 1000 },
{ data: '12/02/19', amount: 1000 },
],
[],
[],
[],
[],
[],
[],
[],
[],
];
const acc = new Array(12).fill([]);
acc.forEach((value, index, arr) => {
if (payments[index] === undefined) { return []; }
console.log(payments[index]);
const total = payments[index].reduce((acc, value) => acc + value.amount)
});