Today's puzzle
What's missing in this code?
const fruits = [
{ name: 'pineapple🍍', color: '🟡' },
{ name: 'apple🍎', color: '🔴' },
{ name: 'banana🍌', color: '🟡' },
{ name: 'strawberry🍓', color: '🔴' },
];
const groupFn =
;
const fruitBaskets = fruits.reduce(
(grouped, obj) => ({
...grouped,
[groupFn(obj)]: [
, obj],
}),
}
{);
console.log(fruitBaskets);
// { '🟡': [ { name: 'pineapple🍍', color: '🟡' }, ... ] }
// '🔴': [ { name: 'apple🍎', color: '🔴' }, ... ] }
Type or select from these options