I can't work out the logic on this one, most of the other questions I've found have different data structures such as arrays of objects with duplicate keys.
I have two arrays of equal length - one is a list of values, the other is a corresponding date. For example:
values = [100,100,95,80,100,100,87,88,90,40];
dates = ['03 Dec', '03 Dec', '04 Dec', '04 Dec', '04 Dec', '04 Dec', '05 Dec', '05 Dec', '06 Dec', '06 Dec'];
The real arrays are much longer, circa 1,000 values with corresponding dates spanning 10 days. I am trying to get the average value for each date to make it much easier to display using apexcharts.
What I am trying to get to is something like this:
values = [100,93.75,87.5,65];
dates = ['03 Dec', '04 Dec', '05 Dec', '06 Dec'];
or indeed:
{03 Dec: '100', 04 Dec: '93.75', 05 Dec: '87.5', 06 Dec: '65'}
I've tried to combine with dates.reduce but I'm stuck with how to average the values for each day.
Any pointers would be gratefully received. Thank you.