JSFiddle - React, Tailwind, and code Playground
by colintoh
JavaScript
// Fork this fiddle before starting on this question
var arr = [
{ 'user': 1, 'restaurant': 2, 'score': 5 },
{ 'user': 2, 'restaurant': 3, 'score': 5 },
{ 'user': 1, 'restaurant': 2, 'score': 2 },
{ 'user': 1, 'restaurant': 2, 'score': 5 },
{ 'user': 2, 'restaurant': 3, 'score': 10 },
{ 'user': 2, 'restaurant': 3, 'score': 10 }
];
/* Expected Aggregated Array
[
{ user: 1, restaurant: 2, totalScore: 12 },
{ user: 2, restaurant: 3, totalScore: 25 }
];
*/
/** Write your answer below **/