Object.groupBybeginner// Group array items by a computed key
const items = [{ type: 'a', v: 1 }, { type: 'b', v: 2 }, { type: 'a', v: 3 }]
Object.groupBy(items, item => item.type)
// β { a: [{...}, {...}], b: [{...}] }Use Object.groupBy() to group an array's elements into an object keyed by a value returned from a callback.
Calling Object.groupBy with an empty array returns an empty object {}.
Challenge: Implement groupEmpty() that calls Object.groupBy([], () => 'x') and returns the result.
groupEmpty() // β {}