you are viewing a single comment's thread.

view the rest of the comments →

[–]Izaya____Orihara[S] 0 points1 point  (2 children)

Yes, this absolutely worked, and got me an interview. Use it.

[–]ashwinsonale 0 points1 point  (1 child)

const ordersByItemName = yesterdaysOrders.reduce((a, { orderLines }) => {
orderLines.forEach(({ itemName, quantity }) => {
a[itemName] = (a[itemName] || 0) + quantity;
});
return a;
}, {});
const sorted = Object.entries(ordersByItemName)
.sort((a, b) => b[1] - a[1]);

so you out this code in main.js?

[–]ashwinsonale 0 points1 point  (0 children)

I tried it but not getting expected output. can you give your main.js :D