Below is an example of an array:
let transactions = [{
date: 2019,
amount: 3000
},
{
date: 2019,
amount: 5500
},
{
date: 2020,
amount: 2300
}
]
I am looking to calculate the total amount for each year, resulting in the following:
{"2019": 8500, "2020": 2300}
Any suggestions on how to achieve this?