How can arrays be superimposed and merged if the array has the same ID and different numbers?

let badge = [{id: 323, badge: 10},{id: 323, badge: 10},{id: 311, badge: 1},{id: 311, badge: 1},{id: 311, badge: 1},{id: 311, badge: 1},{id: 352, badge: 3},{id: 352, badge: 100},{id: 480, badge: 5}]

// 
let badgeMerge = [{id: 323, badge: 20},{id: 311, badge: 4},{id: 352, badge: 103},{id: 480, badge: 5}]

how can this array be superimposed and merged if it has the same ID and different numbers?

May.12,2021

Object.values(badge.reduce((t,c)=>{
    (!t[c.id] && (t[c.id]= c)) || (t[c.id] && (t[c.id].badge += c.badge));
    return t;
}, {}));
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-1e46d19-438a0.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-1e46d19-438a0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?