JSFiddle - React, Tailwind, and code Playground
by ocanal
JavaScript
var recordArr = [];
var SortrRecordArr = [];
recordArr[1] = [1 , 2 , 23];
recordArr[2] = [1 , 2 , 23];
recordArr[3] = [2 , 3 , 8];
recordArr[4] = [2 , 3 , 8];
recordArr[5] = [3 , 4 , 5];
recordArr[6] = [3 , 4 , 5];
for(var key in recordArr){
if (!SortrRecordArr.hasOwnProperty(recordArr[key][2])) {
SortrRecordArr[recordArr[key][2]] = [recordArr[key][0], recordArr[key][1]];
} else {
newValue = SortrRecordArr[recordArr[key][2]][0] + recordArr[key][0];
newValueWithTax = SortrRecordArr[recordArr[key][2]][1] + recordArr[key][1];
SortrRecordArr[recordArr[key][2]] = [newValue, newValueWithTax];
}
}
console.log(SortrRecordArr)