1const FRUITS = ["banana", "apple", "orange", "banana", "orange",
2"apple", "apple", "orange", "orange", "banana", "orange", "banana"];
3
4const total = FRUITS.reduce((map, fruit) => ({
5 ...map,
6 [fruit]: (map[fruit] || 0) + 1,
7}), {});
8console.log(total); // { banana: 4, apple: 3, orange: 5}