const data = [{ Phase: "Phase 1", Step: "Step 1", Task: "Task 1", Value: "5", Status: "Done", Month: "May" },
{ Phase: "Phase 1", Step: "Step 1", Task: "Task 2", Value: "10", Status: "Started", Month: "May" },
{ Phase: "Phase 1", Step: "Step 2", Task: "Task 1", Value: "15", Status: "Done", Month: "June" },
{ Phase: "Phase 1", Step: "Step 2", Task: "Task 2", Value: "20", Status: "Started", Month: "Aug" },
{ Phase: "Phase 2", Step: "Step 1", Task: "Task 1", Value: "25", Status: "Done", Month: "Apr" },
{ Phase: "Phase 2", Step: "Step 1", Task: "Task 2", Value: "30", Status: "NotStarted", Month: "May" },
{ Phase: "Phase 2", Step: "Step 2", Task: "Task 1", Value: "35", Status: "Done", Month: "Oct" },
{ Phase: "Phase 2", Step: "Step 2", Task: "Task 2", Value: "40", Status: "NotStarted", Month: "Dec" }];
const keys = ["Phase", "Step"];
function matches(table, entry, keys) { // finds item with same values
return table.find(e => keys.every(k => e[k] == entry[k]));
}
const result = data.reduce((cur, val) => {
let alreadyIn = matches(cur, val, keys);
if (alreadyIn) {
alreadyIn['Value'] = (parseInt(alreadyIn['Value']) + parseInt(val['Value'])).toString();
} else {
cur.push(val);
}
return cur;
}, []);
console.log(result);