Question: I want to make an array of objects grouped by the date property.

```
let data = [
        { Age: "(60-100)", Date: "28/05/20" },
        { Age: "(60-100)", Date: "28/05/20" },
        { Age: "(4-6)", Date: "28/05/20" },
        { Age: "(60-100)", Date: "29/05/20" },
        { Age: "(38-43)", Date: "29/05/20" },
        { Age: "(4-6)", Date: "29/05/20" },
        { Age: "(38-43)", Date: "30/05/20" },
        { Age: "(38-43)", Date: "30/05/20" }
    ];

```

I want the output like

```
 result = [
        { Date: "28/05/20", "(60-100)": 2, "(4-6)": 1 },
        { Date: "29/05/20", "(38-43)": 1, "(4-6)": 1, "(60-100)": 1 },
        { Date: "30/05/20", "(38-43)": 2 },
    ]

```

Answer: 
Give this a try.

```
 let data = [
      { Age: "(60-100)", Date: "28/05/20" },
      { Age: "(60-100)", Date: "28/05/20" },
      { Age: "(4-6)", Date: "28/05/20" },
      { Age: "(60-100)", Date: "29/05/20" },
      { Age: "(38-43)", Date: "29/05/20" },
      { Age: "(4-6)", Date: "29/05/20" },
      { Age: "(38-43)", Date: "30/05/20" },
      { Age: "(38-43)", Date: "30/05/20" }
 ];

 let res = [];
 data.map((d, index) => {
      if (!res.some(val => val.Date === d.Date)) {
           d[`${d.Age}`] = 1
           res.push(d)
           delete(d.Age)
      } else {
           let index = res.findIndex(val => val.Date == d.Date);
           let _d = res[index];
           if (_d.hasOwnProperty(`${d.Age}`)) {
                _d[`${d.Age}`] = parseInt(_d[`${d.Age}`] + 1)
           } else {
                _d[`${d.Age}`] = 1
           }
           res[index] = _d;
      }
 })

 console.log(res)

```
Condensed version based on @Dante Culaciati approach with optional sort parameter.

```js
const condenseAge = (arr, isSort = true) => {
    let r = [];
    arr.map((val) => {
        let i = r.findIndex(obj => obj.Date == val.Date);
        (i < 0) && r.unshift({Date: val.Date}) && (i = 0);
        (!r[i][val.Age]) ? r[i][val.Age] = 1 : r[i][val.Age]++;
    });
    return !isSort?r:r.sort((a,b)=>(ac=a['Date'].split('/'), bc=b['Date'].split('/'), new Date(ac[2],ac[1],ac[0]) - new Date(bc[2],bc[1],bc[0])));
}
console.log(condenseAge([
    { Age: "(4-6)", Date: "02/06/20"},
    { Age: "(60-100)", Date: "28/05/20" },
    { Age: "(60-100)", Date: "28/05/20" },
    { Age: "(4-6)", Date: "28/05/20" },
    { Age: "(60-100)", Date: "29/05/20" },
    { Age: "(38-43)", Date: "29/05/20" },
    { Age: "(4-6)", Date: "29/05/20" },
    { Age: "(38-43)", Date: "30/05/20" },
    { Age: "(38-43)", Date: "30/05/20" }
]));
```