JSFiddle - React, Tailwind, and code Playground
HTML
<pre id="result"></pre>
JavaScript
var grants = [
{ id: "p_1", location: "loc_1", type: "A", funds: "5000" },
{ id: "p_2", location: "loc_2", funds: "2000" },
{ id: "p_3", location: "loc_3", type: "C", funds: "500" },
{ id: "p_2", location: "_ibid", funds: "1000" },
{ id: "p_2", location: "_ibid", type: "E", funds: "3000" }
];
var projects = [];
grants.map(
function (v) {
if (!(v.id in this)) {
this[v.id] = v;
projects.push(v);
} else {
var current = this[v.id];
current.type = [v.type].concat(current.type);
current.funds = [v.funds].concat(current.funds);
}
}, {});
document.querySelector('#result').textContent = JSON.stringify(projects, null, 2);