What would be the best way to sort myarr into sortedArr so that all of the values have been added together for each invidual id using javascript?
myarr = [{id: 10, val:100}, {id:10, val: 100}, {id:20, val:200}, {id:20, val:100}, {id:30, val:100}]
sortedArr = [{id: 10, val: 200}, {id:20, val:300}, {id:30, 100}]