This is an array of objects I want to get a count of the duplicate objects in the array. What is the most concise and efficient way to find out duplicate objects?
[
{
partNum: 'ACDC1007',
brandName: 'Electric',
supplierName: 'Electric',
},
{
partNum: 'ACDC1007',
brandName: 'Electric',
supplierName: 'Electric',
},
{
partNum: 'ACDC1007',
brandName: 'Electric',
supplierName: 'Electric',
},
{
partNum: 'ACDC1009',
brandName: 'Electric',
supplierName: 'Electric',
},
{
partNum: 'ACDC1000',
brandName: 'Electric',
supplierName: 'Electric',
}
]
I am looking for a way to modify the array of objects on the basis of partNum like this:
[
{
partNum: 'ACDC1007',
brandName: 'Electric',
supplierName: 'Electric',
count: 3
},
{
partNum: 'ACDC1007',
brandName: 'Electric',
supplierName: 'Electric',
count: 3
},
{
partNum: 'ACDC1007',
brandName: 'Electric',
supplierName: 'Electric',
count: 3
},
{
partNum: 'ACDC1000',
brandName: 'Electric',
supplierName: 'Electric',
count: 1
}
.............
] ```
Thanks