title: Data wrangling in js: Calculate cumulative count and add missing consecutive dates in javascript
body: <p>I have an array of objects with the following structure:</p>
  <pre><code>var data = [
  {date: 2020-01-01, value: 1},
  {date: 2020-01-03, value: 2},
  {date: 2020-01-04, value: 2},
  {date: 2020-01-07, value: 8}
  ]
  </code></pre>
  <p>How can I calculate a cumulative count and add the missing dates in between using javascript? I would like to get the following result:</p>
  <pre><code>var data = [
  {date: 2020-01-01, value: 1, cumulativeValue: 1},
  {date: 2020-01-02, value: 0, cumulativeValue: 1},
  {date: 2020-01-03, value: 2, cumulativeValue: 3},
  {date: 2020-01-04, value: 2, cumulativeValue: 5},
  {date: 2020-01-05, value: 0, cumulativeValue: 5},
  {date: 2020-01-06, value: 0, cumulativeValue: 5},
  {date: 2020-01-07, value: 8, cumulativeValue: 13}
  ]
  </code></pre>
  <p>I started mapping the data and including the index to loop over the dates but I am unsure about what's the best way to go after that:</p>
  <pre><code>data.map((d,i) =&gt; {
  
    return {
    
  
    }
  
  })
  
  
  </code></pre>