title: Group simple array of dates "yyyy-mm-dd" by week and month in JavaScript
body: <p>I would like to group a simple date array by <strong>week and month</strong> (in an array). I know there are many examples, and the question has been asked many times, but I cannot find an example on a very simple date format, and not a date-time stamp.</p>
  <p><strong>My date data array looks like this:</strong></p>
  <pre><code>&quot;timeline_data&quot;: [
    &quot;2016-12-20&quot;,
    &quot;2016-12-21&quot;,
    &quot;2016-12-22&quot;,
    &quot;2016-12-23&quot;,
    &quot;2016-12-24&quot;,
    &quot;2016-12-25&quot;,
    &quot;2016-12-26&quot;,
    &quot;2016-12-27&quot;,
    &quot;2016-12-28&quot;,
    &quot;2016-12-29&quot;,
    &quot;2016-12-30&quot;,
    &quot;2016-12-31&quot;,
    &quot;2017-01-01&quot;,
    &quot;2017-01-02&quot;,
    &quot;2017-01-03&quot;,
    &quot;2017-01-04&quot;,
    &quot;2017-01-05&quot;,
    &quot;2017-01-06&quot;,
    &quot;2017-01-07&quot;,
    &quot;2017-01-08&quot;,
    &quot;2017-01-09&quot;,
    &quot;2017-01-10&quot;
  ]
  </code></pre>
  <p><strong>This is what is getting me:</strong> I am not sure whether there is an easy way of looping through this array, and simple pushing the items into new arrays, or whether the date will have to be modified, and the &quot;-&quot; removed with something like:</p>
  <pre><code>var date=&quot;2016-12-20&quot;;
  var newDate = date.replace(/-/g, &quot;&quot;);
  </code></pre>
  <p>And then obviously, the &quot;-&quot; will have to be replaced.</p>
  <p>I hope there is a simpler way.</p>