July 12th, 2024
What's missing in this code?
const colors = ['🔴', '🔴', '🟢', '🔵', '🔴', '🟡'];
const colorCount = colors.
(
(obj, color, index) => (
...obj,
[
]: obj[color] ?
: 1,
}),
{}
);
// { '🔴': 3, '🟢': 1, '🔵': 1, '🟡': 1 }
Type or select from these options