Sum values from two arrays

I have two arrays:

allocatedHours: {{id:"", totalHours:12, week:fn!date(2020, 07, 31)}; {id:"", totalHours:12, week:fn!date(2020, 08, 7)}; {id:"", totalHours:48, week:fn!date(2020, 08, 14)}; {id:"", totalHours:48, week:fn!date(2020, 08, 21)}}

proposedHours: {{id:"", totalHours:36, week:fn!date(2020, 07, 31)}; {id:"", totalHours:42, week:fn!date(2020, 08, 7)}; {id:"", totalHours:48, week:fn!date(2020, 08, 14)}; {id:"", totalHours:54, week:fn!date(2020, 08, 21)}}

I am wanting to return TotalHours where allocatedHours.week = proposedHours.week.

When I do a forEach on weeks, it only ever returns the first value for each week, ie {31/7/2020, 48}, {7/8/2020, 48}, {14/8/2020,48}, {21/8/2020, 48).

How do I make if return the correct value for each week, ie {31/7/2020, 48}, {7/8/2020, 54}, {14/8/2020,96}, {21/8/2020, 102).

  Discussion posts and replies are publicly visible

Parents Reply Children
No Data