title: Accumulate number of records in a hourly time range
body: <p>I will explain this to the best of my ability.</p>
  
  <p>I have a series of unique dates in the form of DD/MM/YYYY as shown below:</p>
  
  <pre><code>const sortDates = [
  '14/04/2018',
  '12/04/2018',
  '10/04/2018',
  ]
  </code></pre>
  
  <p>and then I have an array of objects with the following information.</p>
  
  <pre><code>const bookings = [
    { bookingStart: '2018-04-14 00:30:00' },
    { bookingStart: '2018-04-14 00:42:00' },
    { bookingStart: '2018-04-14 13:35:00' },
    { bookingStart: '2018-04-12 12:30:00' },
  ];
  </code></pre>
  
  <p>And what i am trying to achieve is finding and grouping data on an hourly basis per day. Example below:</p>
  
  <pre><code>const groupedData = [{
    date: '2018-04-14',
    period : {
       startTime: '00:00',
       endTime: '00:59',
       total: 2, //total bookings found 2018/04/14 00:00 -&gt; 00:59
    },
    date: '2018-04-14',
    period : {
       startTime: '01:00',
       endTime: '01:59',
       total: 0,  //total bookings found 2018/04/14 01:00 -&gt; 01:59
    },
    ...etc
  }
  </code></pre>
  
  <p>however i am a little stuck. My current code is as follows, and unsure how the return statement should be:</p>
  
  <pre><code>const groupData = sortDates.map((date) =&gt; {
    for (let i = 0; i &lt;= 23; i += 1) {
      const startTime = new Date(date);
      const endTime = new Date(date);
      startTime.setHours(i);
      startTime.setMinutes(0);
      startTime.setSeconds(0);
      startTime.setMilliseconds(0);
      endTime.setHours(i);
      endTime.setMinutes(59);
      endTime.setSeconds(0);
      endTime.setMilliseconds(0);
      bookings.map((booking) =&gt; {
        const dateTime = new Date(booking.bookingStart);
        if (startTime.getTime() &gt;= dateTime.getTime()
        &amp;&amp; dateTime.getTime() &lt;= endTime.getTime()) {
          return {
            date: dateTime,
          };
        }
        return null;
      });
    }
    return null;
  });
  </code></pre>
  
  <p>Not even sure if is the nicest or fastest way to do it, but how would i do a return in the format i want? any faster alternatives?</p>