177. Implement Object.groupBy()

JavaScript

medium  - accepted / - tried

Object.groupBy() allows us to easily group array items, please try to implement it by yourself.

const items = [  {    id: 1,    kind: 'a',  },  {    id: 2,    kind: 'b',  },  {    id: 3,    kind: 'a',  }]const groups = Object.groupBy(items, ({kind}) => kind)// {//   a: [//     {//       id: 1,//       kind: 'a'//     },//     {//       id: 3,//       kind: 'a'//     }//   ],//   b: [//     {//       id: 2,//       kind: 'b'//     }//   ]// }

Always try to find a better approach.