mediumJavaScript

Implement Array Group By

Create a function that groups array elements based on a given key or callback function. Example: Input: [{age:20},{age:30},{age:20}] Output: {20:[...],30:[...]}
Ensure function signatures match starter code to run test cases.
index.js
Loading...

Test Case #1

Input: [{"type":"a"},{"type":"b"},{"type":"a"}],type

Expected: {"a":[...],"b":[...]}