This is my example data. I want to group the data by month and count which month has the most data and return 1 data per month which is the most appliancesType and count.
appliances:[
{
"appliancesType": "Oven",
"createdAt": "2022-09-06"
}, {
"appliancesType": "Oven",
"createdAt": "2022-11-27"
},{
"appliancesType": "Television",
"createdAt": "2022-07-03"
},{
"appliancesType": "Television",
"createdAt": "2022-07-03"
}, {
"appliancesType": "Oven",
"createdAt": "2022-09-26"
}];
I expecting the result like this.
appliances:[
{
"appliancesType": "Television",
"createdAt": "2022-07-03",
"count": 2
},
{
"appliancesType": "Oven",
"createdAt": "2022-09-26",
"count": 2
},
{
"appliancesType": "Oven",
"createdAt": "2022-11-27",
"count": 1
},
]
So, how to solve this kind of problem in JavaScript?