So I have an array of objects that looks like:
dataArray = [
{Revenue: 5, Date: "2018-06-05T00:00:00", DateString: "6/5/2018"},
{Revenue: 10, Date: "2018-06-05T00:00:00", DateString: "6/5/2018"},
{Revenue: 5, Date: "2018-06-05T00:00:00", DateString: "6/5/2018"},
{Revenue: 1, Date: "2018-06-13T00:00:00", DateString: "6/13/2018"},
{Revenue: 4, Date: "2018-06-13T00:00:00", DateString: "6/13/2018"}
]
And what I need is to reduce that down to another array of objects that looks like:
reducedDataArray = [
{Revenue: 20, Date: "2018-06-05T00:00:00", DateString: "6/5/2018"},
{Revenue: 5, Date: "2018-06-13T00:00:00", DateString: "6/13/2018"}
]
Basically if the date is the same then the revenue needs to be summed up so that there aren't multiple instances of the same date. Unfortunately I am limited to our version of Typescript so I don't have all the cool ES6 goodies to help with this stuff. I've tried using things like reduce() but I think a combination of not knowing what the heck I'm doing and this being kind of weird has left me in a fog.
Any suggestions or insight would be greatly appreciated!