let obj={};
[{name: 'one', q: 5}, {name: 'one', q: 3}, {name: 'two', q: 1},{name: 'two', q: 6},{name: 'three', q: 10}].forEach(entry=>{
if(obj[entry.name]){
obj[entry.name].q+= entry.q;
}else{
obj[entry.name]= entry;
}
});
console.log(Object.values(obj));
//Or ES5 way
console.log(Object.keys(obj).map(name=>obj[name]));
const arr = [{name: "one", q: 5},{name: "one", q: 3},{name: "two", q: 1},{name: "two", q: 6},{name: "three", q: 10}]
const result = arr.reduce((acc, obj) => {
let index = acc.findIndex((elm) => {return elm.name == obj.name});
if(index == -1){ return acc.concat(Object.assign({}, obj) };
acc[index]['q'] += obj.q;
return acc
}, [])