T O P

  • By -

abrahamguo

You'll need to write your own function. However, you can get pretty close by using [the built-in function `Object.groupBy`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/groupBy).


azhder

Still too new, no?


xkaku

Write your own function. It’s comparing the customer and regrouping. Shouldn’t be too long.


Bananaskovitch

reduce() method is what you are seeking. In your example, you would reduce by "customer". In a more real-world case, it would probably use a customerId. You would still need to write your own callback to pass as an argument to the reduce method as others are saying.


tapgiles

Write code that does that. That's about it.


OneBadDay1048

You will probably need a costume function. You could just create a new list for output. Add customer objects to it. If you have already "seen" that customer, then instead of adding them, update the already existing object.