title: How to make an array of objects an object grouped by day?
body: <p>So I have an array of items, each with a date (from the moment library) and some text.</p>
  
  <p>I am able to successfully turn this into an object of objects however if two or more objects have the same day, as it is mapped over it rewrites the previous item with the new one.</p>
  
  <p>I must organize the object of objects based on YYYY-MM-DD format.</p>
  
  <p>For example, the items array might look like this when it is console logged-</p>
  
  <pre><code>Array [
    Object {
      "date": 2019-08-06T19:10:00.000Z,
      "id": 0,
      "text": "Item1",
    },
    Object {
      "date": 2019-08-06T22:10:00.000Z,
      "id": 1,
      "text": "Item2",
    },
  ]
  </code></pre>
  
  <p>this is the code I am using to turn it into an object of objects</p>
  
  <pre><code>const calItemsArray = Object.assign({}, 
        ...this.props.items.map(item =&gt; 
          ({ [moment(item.date).format('YYYY-MM-DD')]: [{
            text: item.text, time: moment(item.date).format('h:mm a') }] 
          }))
        );
        console.log(calItemsArray);
  </code></pre>
  
  <p>This is what would be console logged from calItemsArray based on the given data (two items with the same date)</p>
  
  <pre><code>Object {
    "2019-08-06": Array [
      Object {
        "text": "Item2", //item one seems to be overwritten
        "time": "6:10 pm",
      },
    ],
  }
  </code></pre>
  
  <p>I would like each date to contain all of the texts and the time of items that have that date. However if one already exists, instead of adding it to the dates array of objects it just rewrites the date's object itself.</p>