function groupBy(list, propName) { return list.reduce((acc, item) => { const key = item[propName]; if (!acc[key]) { acc[key] = []; } acc[key].push(item); return acc; }, {}); }