Javsacript. How to manipulate array of objects so it groups elements that have the same element? : <p>I have an array like the following, that I will fetch from MongoDB:</p>

<pre><code>[
  {date: '2019-10-05', score: 3},
  {date: '2019-10-05', score: 5},
  {date: '2019-10-06', score: 4},
  {date: '2019-10-06', score: 1},
]
</code></pre>

<p>I need to make a new array to look like the following:</p>

<pre><code>[
  {date: '2019-10-05', score: [3,5]},
  {date: '2019-10-06', score: [4,1]}
]
</code></pre>

<p>Basically grouping the scores into the same arrays based on the date attribute. Any kinds of advice to achieve this is appreciated.</p>
