data
[
{
desc: "Taxi",
amt: 50,
ctg: "Travelling",
time: "Thu May 09 2022 12:05:13",
},{
desc: "Fruits",
amt: 300,
ctg: "Food",
time: "Wed Jul 06 2022 12:05:13",
},{
desc: "Taxi",
amt: 50,
ctg: "Travelling",
time: "Fri Jun 26 2021 12:05:13",
},{
desc: "Books",
amt: 1000,
ctg: "Study",
time: "Mon Apr 16 2021 12:05:13",
},{
desc: "Taxi",
amt: 50,
ctg: "Travelling",
time: "Fri May 21 2023 12:05:13",
}
]
Desired Output
[
{
desc: "Fruits",
amt: 300,
ctg: "Food",
count: 1,
},{
desc: "Books",
amt: 1000,
ctg: "Study",
count: 1,
},{
desc: "Taxi",
amt: 50,
ctg: "Travelling",
count: 3,
}
]
I have a Data array of objects with similar fields. I need to get an combined output of the Data only on the basis of desc, amt and ctg when they all are repeated, regardless of the time. How is that possible using Data.map() ??