title: How to create a json grouped by date in js?
body: <p>I have an array of objects sorted by date:</p>
  
  <pre><code>const alerts = [{ 
      id: 1, date: '2018-10-31T23:18:31.000Z', name: 'Joke', title: 'this is the first 1' 
  }, { 
      id: 2, date: '2018-10-30T23:18:31.000Z', name: 'Mark', title: 'this is the second one' 
  }]
  </code></pre>
  
  <p>I am trying to 'group' the alerts by date so trying to create 'datesections' which have a dateheader, the result should be something like:</p>
  
  <pre><code>const sections = [{
     date: '2018-10-31T23:18:31.000Z',
     heading: 'today',
     alerts: [{ id: 1, date: '2018-10-31T23:18:31.000Z', name: 'Joke', 
     title: 'this is the first one' }]
  }, {
     date: '2018-10-30T23:18:31.000Z',
     heading: 'Yesterday',
     alerts: [{ id: 2, date: '2018-05-30T23:18:31.000Z', name: 'Mark', 
     title: 'this is the second one' }]
  }]
  </code></pre>
  
  <p>I tried something this but can't figure out how to get the alerts with the same date in the alerts prop:</p>
  
  <pre><code>const sections2=alerts.map(a =&gt;
      ({
          date: a.date,
          heading:'today new',
          alerts:alerts
      })
  )
  </code></pre>