I'm counting the customer occurrences using reduce like this. Then, I need to display the customer who appear more than 3 times. It works actually, but only display the count because I'm using map.values(). I want it to display the customer name too. Anyone know how to do it? thank you!
const customer = ["Andy", "Drew", "Andy", "Brian", "Andy", "Brian", "Andy", "Brian", "Brian", "Drew", "Brian"];
const custFreq = customer.reduce((acc, curr) => acc.set(curr, (acc.get(curr) || 0) + 1), new Map());
const result = [...custFreq.values()].filter((curr) => curr >= 3.0);
console.log(result);
result => { 4, 5 }
expected result => { Andy: 4, Brian: 5 }