I using code form "
I am looking for best ways of doing this. I have group:  

**data**

```js
[
  {
     "date": "16/04/2020",
     "count": 0,
     "name": "A"
  },
  {
     "date": "16/04/2020",
     "count": 1,
     "name": "B"
  },
  {
     "date": "17/04/2020",
     "count": 0,
     "name": "B"
  }                     
  //...More.....
]

```

**Answer**

```js
{
    "date": "04/2020",
    "symtom": {
        "data": [
            {
                "date": "16/04/2020",
                "data": [
                    {
                        "name": "A",
                        "count": [
                            {
                                "date": "16/04/2020",
                                "count": 0,
                                "name": "A"
                            }
                        ]
                    },
{
                        "name": "B",
                        "count": [
                            {
                                "date": "16/04/2020",
                                "count": 1,
                                "name": "B"
                            }
                        ]
                    },
                    //...More.....
                ]
            },
            {
                "date": "17/04/2020",
                "data": [
                    {
                        "name": "B",
                        "count": [
                            {
                                "date": "17/04/2020",
                                "count": 0,
                                "name": "B"
                            }
                        ]
                    },
                    //...More.....
                ]
            }
        ]
    }
}
```

Can I fix the code and to get the desired answer? 

**Code :**

```js
const items = [
  {
    tab: 'Results',
    section: '2017',
    title: 'Full year Results',
    description: 'Something here',
  },
    {
    tab: 'Results',
    section: '2017',
    title: 'Half year Results',
    description: 'Something here',
  },
    {
    tab: 'Reports',
    section: 'Marketing',
    title: 'First Report',
    description: 'Something here',
  }
];

function groupAndMap(items, itemKey, childKey, predic){
    return _.map(_.groupBy(items,itemKey), (obj,key) => ({
        [itemKey]: key,
        [childKey]: (predic && predic(obj)) || obj
    }));
}

var result = groupAndMap(items,"tab","sections", 
                   arr => groupAndMap(arr,"section", "items"));

console.log(result);
```

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"></script>
```

ref : [Group array of object nesting some of the keys with specific names](https://stackoverflow.com/questions/48425797/group-array-of-object-nesting-some-of-the-keys-with-specific-names#)  

**But I would like to have the answer line this (Answer) :**

```js
{
    "date": "04/2020",
    "symtom": {
        "data": [
            {
                "date": "16/04/2020",
                "data": [
                    {
                        "name": "A",
                        "count":  0,
                    },
                    {
                        "name": "B",
                        "count":  1,
                    },
                    //...More.....
                ]
            },
            {
                "date": "17/04/2020",
                "data": [
                    {
                        "name": "B",
                        "count":0,
                    },
                    //...More.....
                ]
            }
        ]
    }
}
```

Thanks!