title: Reducing an JavaScript Array of objects with dates as keys?
body: <p>The app I'm working with is outputting an array in javascript like this:</p>
  <pre><code> let realData = [];
      realData.push({&quot;2021-01-01&quot;:&quot;5,000&quot;,&quot;2021-02-01&quot;:&quot;5,000&quot;,
                    &quot;2021-03-01&quot;:&quot;5,000&quot;,&quot;2021-04-01&quot;:&quot;5,000&quot;,
                    &quot;2021-05-01&quot;:&quot;5,000&quot;,&quot;2021-06-01&quot;:&quot;5,000&quot;,
                    &quot;2021-07-01&quot;:&quot;5,000&quot;,&quot;2021-08-01&quot;:&quot;5,000&quot;,
                    &quot;2021-09-01&quot;:&quot;5,000&quot;,&quot;2021-10-01&quot;:&quot;5,000&quot;,
                    &quot;2021-11-01&quot;:&quot;5,000&quot;,&quot;2021-12-01&quot;:&quot;5,000&quot;});
      realData.push({&quot;2021-01-01&quot;:&quot;5,000&quot;,&quot;2021-02-01&quot;:&quot;5,000&quot;,
                     &quot;2021-03-01&quot;:&quot;5,000&quot;,&quot;2021-04-01&quot;:&quot;5,000&quot;,
                     &quot;2021-05-01&quot;:&quot;5,000&quot;,&quot;2021-06-01&quot;:&quot;5,000&quot;,
                     &quot;2021-07-01&quot;:&quot;5,000&quot;,&quot;2021-08-01&quot;:&quot;5,000&quot;,
                     &quot;2021-09-01&quot;:&quot;5,000&quot;,&quot;2021-10-01&quot;:&quot;5,000&quot;,
                     &quot;2021-11-01&quot;:&quot;5,000&quot;,&quot;2021-12-01&quot;:&quot;5,000&quot;});
      realData.push({&quot;2021-01-01&quot;:&quot;5,000&quot;,&quot;2021-02-01&quot;:&quot;5,000&quot;,
                     &quot;2021-03-01&quot;:&quot;5,000&quot;,&quot;2021-04-01&quot;:&quot;5,000&quot;,
                     &quot;2021-05-01&quot;:&quot;5,000&quot;,&quot;2021-06-01&quot;:&quot;5,000&quot;,
                     &quot;2021-07-01&quot;:&quot;5,000&quot;,&quot;2021-08-01&quot;:&quot;5,000&quot;,
                     &quot;2021-09-01&quot;:&quot;5,000&quot;,&quot;2021-10-01&quot;:&quot;5,000&quot;,
                     &quot;2021-11-01&quot;:&quot;5,000&quot;,&quot;2021-12-01&quot;:&quot;5,000&quot;});
  
  console.log(realData);
  </code></pre>
  <p>Each line has 12 entries (for each month).</p>
  <p>I'm looking at an effective way to cycle through them and sum the same month; combining each object so Jan 2021 would show 20,000 from the above.</p>
  <p>I've previously used this code:</p>
  <pre><code> var foo = _.chain(data)
              .groupBy('month')
              .map(function (objects, period) {
                  return {
                      month: period,
                      value: _.sumBy(objects, item =&gt; Number(item.value)),
  
                  };
              })
              .value();
  </code></pre>
  <p>which worked really well; but the data I'm using doesn't have named keys (i.e. before I had a JSON file that looked like this:</p>
  <pre><code>[
      {
  
          &quot;month&quot;: &quot;2020-06-01&quot;, 
          &quot;value&quot;: &quot;2500.00&quot;,
   
      }, ..
  </code></pre>
  <p>Is what I'm trying to achieve possible or do I need to revisit how the data is being stored?</p>