What's the best way to get duplicates in an array of hashes with strings and count number of appearances.
If I have this array of hashes
const data = [
{
url: 'https://app.mywebsite.net/endpoint1',
method: 'POST'
},
{
url: 'https://app.mywebsite.net/endpoint2',
method: 'POST'
},
{
url: 'https://app.mywebsite.net/endpoint1',
method: 'POST'
}
]
And I want to get the hashes that are duplicated and the amount of times they appear like
{
url: 'https://app.mywebsite.net/endpoint1',
method: 'POST',
count: 2
},
{
url: 'https://app.mywebsite.net/endpoint2',
method: 'POST',
count: 1
},
Javascript - Counting duplicates in object array and storing the count as a new object
names.reducetodata.reduceand[o.cat, o.sub]to[o.url, o.method].