x
You solved the puzzle!
There's a new one coming soon 😉
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
{}
[]
0
obj[color]
obj[color]++
obj[color] + 1
reduce
index
color
split
join
CHECK