I have a JSON array like this :
var data = [
{title: "HH02"},
{title: "HH03"},
{title: "HH04"},
{title: "HH02"},
{title: "HH07"},
{title: "HH08"},
{title: "HH08"},
{title: "HH10"},
{title: "HH02"},
{title: "HH11"}
]
First I would like to get repeated objects in JSON array like this:
var output = [
{title: "HH02" },
{title: "HH08" },
]
Then I would like to get all repeated objects and how many times they are repeated in another JSON array like this
var output = [
{title: "HH02" , repeat: 3},
{title: "HH08" , repeat: 2},
]
I tried doing this, but it didn't work well:
data.map(v => v.title).sort().sort((a, b) => {
if (a === b) output.push(a);
})