js-group-by.js
const orders = [
{ customer: "ada", total: 30 },
{ customer: "linus", total: 12 },
{ customer: "ada", total: 8 },
];
const byCustomer = orders.reduce((acc, order) => {
(acc[order.customer] ||= []).push(order);
return acc;
}, {});
console.log(byCustomer);