Arrays & Array Methods (map, filter, reduce)
What data transformation is being performed?
const records = [
{ id: 1, value: 10 },
{ id: 2, value: 20 },
{ id: 1, value: 30 }
];
const merged = records.reduce((acc, curr) => {
acc[curr.id] = (acc[curr.id] || 0) + curr.value;
return acc;
}, {});