title: Javascript fill missing dates with day and 0 count in array
body: <p>I have an array generated through a code where I'm calculating, for each day from now to 7 days ago, the daily occurrences. Right now my code is skipping the days where there aren't occurrences, but I would like to insert those days together with a 0 count value. Here's my code:</p>
  <pre><code>var myObj;
  fetch('https://blahblahblah?'+param1+param2+&quot;FromDate&quot;+&quot;=&quot;+moment().subtract(7,'d').format('YYYY-MM-DD'))
  .then(res=&gt;res.json())
  .then(data=&gt;myObj= data);
  
  var myRes= [];
  
  myObj.forEach(function (elem) {
      var date = elem.CreatedDate.split(' ')[0];
  
  
      if (myRes[date]) {
          myRes[date] += 1;
      } else {
          myRes[date] = 1;
      }
  });
  </code></pre>
  <p>Right now I'm getting a similar result:</p>
  <pre><code>2020-12-11: 1
  2020-12-12: 2
  2020-12-13: 1
  2020-12-15: 2
  2020-12-16: 1
  </code></pre>
  <p>Because on 12-10 I didn't have any value and on 12-14 neither. Given the startTime <code>moment().subtract(7,'d').format('YYYY-MM-DD')</code></p>
  <p>how can I output the days with 0 values like in the format below?:</p>
  <pre><code>2020-12-10: 0
  2020-12-11: 1
  2020-12-12: 2
  2020-12-13: 1
  2020-12-14: 0
  2020-12-15: 2
  2020-12-16: 1
  </code></pre>
  <p>Thank you very much</p>
  <p>Edit: here's my obj:</p>
  <pre><code>[{Id, Var1, Var2, CreationDate},
  {1, 123, Var2, 2020-12-11},
  {2, 1234, Var2, 2020-12-12},
  {3, 12345, Var2, 2020-12-12},
  {4, 1234, Var2, 2020-12-13},
  {5, 321, Var2, 2020-12-15},
  {6, 3214, Var2, 2020-12-15},
  {7, 5432, Var2, 2020-12-16}]
  </code></pre>