My array of objects is structured like this:
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"}
]
I am looking to condense this array into another set of objects that appear as follows:
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"}
]
The goal is to aggregate the revenue for entries with the same date. Limited by our version of TypeScript, I lack access to newer functionalities like ES6 features. Although I have attempted using methods like reduce(), I am struggling to navigate its intricacies in this context.
If you have any suggestions or insights on how to accomplish this task, your input would be greatly valued!