Combination and de-duplication of js numbers

let arr= [{id:1,value:2}, {id:2,value:6}, {id:1,value:4}, {id:2,value:1}] is finally converted to
[{id:1,value:6}, {id:2,value:7}]

Dec.07,2021

var arr1 = [];
for(var i = 0 ;i < arr.length ; iPP){
    var obj = arr[i];
    for(var j = i + 1 ; j < arr.length ; jPP){
        if(obj.id == arr[j].id){
            obj.value += arr[j].value;
            arr.splice(j,1);
            j--;
        }    
    }
    arr1.push(obj);
}

let uniq=new Map()
// 
for(let i=0;i<arr.length;iPP){
    let id=arr[i].id,val=arr[i].value
    if(uniq.has(id)) uniq.set(id,uniq.get(id)+val)
    else uniq.set(id,val)
}
let res=[]
// 
for(let comb of uniq){
    res.push({
        id:comb[0],
        value:comb[1]
    })
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b34f78-e4a6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b34f78-e4a6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?