I am struggling with a problem. I want to Spilt JSON objects to another javascript arrays objects using javascript. The JSON should be split the last element of the array. it means `{ href: '/Local1', label: 'Local1', group: 'Local', active: ' active' }` and `{ href: '/Local2', label: 'Local2', group: 'Local', active: ' active' }` should contain in `Local` array. `{ href: '/Foreign1', label: 'Foreign1', group: 'Foreign', active: '' }` and `{ href: '/Foreign1', label: 'Foreign1', group: 'Foreign', active: '' }` should be in `Forign` array.

I have mentioned the tried code below. But my code doesn't give me the expected output. What should I do to get the expected output?

```
exports.getMenu = function (selected, username) {
  const menu = [
    [
      ['/Local1', 'Local1', 'Local'],
      ['/Local2', 'Local2', 'Local'],
      ['/Foriegn1', 'Foriegn1', 'Foriegn'],
      ['/Foriegn2', 'Foriegn2', 'Foriegn'],
    ],
  ];

  const xxx = setMenuGroup(selected, menu);
  console.log(xxx);
  return xxx;

}

```

Current Output:

```
[
  [
    { href: '/Local1', label: 'Local1', group: 'Local', active: ' active' },
    { href: '/Local2', label: 'Local2', group: 'Local', active: '' },
    { href: '/Forign1', label: 'Forign1', group: 'Forign', active: '' },
    { href: '/Forign2', label: 'Forign2', group: 'Forign', active: '' }
  ]
]

```

Expected output:

```
{
  Local: [
    { href: '/Local1', label: 'Local1', group: 'Local', active: ' active' },
    { href: '/Local2', label: 'Local2', group: 'Local', active: '' },
  ],
  Forign: [
    { href: '/Forign1', label: 'Forign1', group: 'Forign', active: '' },
    { href: '/Forign2', label: 'Forign2', group: 'Forign', active: '' }
  ],
}

```