How would I take the following array in JavaScript
locationList = [{
id: 1,
title: "Loughborough"
}, {
id: 5,
title: "Corby"
}, {
id: 2,
title: "Derby"
}, {
id: 2,
title: "Derby"
}, {
id: 2,
title: "Derby"
}];
and convert it into something like this:
locationList = [{
id: 1
title: "Loughborough",
count: 1
}, {
id: 5
title: "Corby",
count: 1
}, {
id: 2
title: "Derby",
count: 3
}];
wherein all the titles are totalled up.