How to reference a previous iteration in forEach in subsequent iterations

Certified Senior Developer

My use case is as follows:

I have a CDT of dates and number of days.  I have the first date, but the others are not populated yet.  My goal is to populate each subsequent date with the previous indexes date + the number of days of the current iteration.

For example I start with the following:

{9/27/2021, 0}, {null,3}, {null,5}

I want the output to be as follows:

{9/27/2021, 0}, {9/30/2021,3}, {10/5/2021,5}

Each iteration will reference the previous iteration's date to generate its own date.

I appreciate your time and help!

  Discussion posts and replies are publicly visible