merge values together in a 2d array
Solution 1:
You could just use an Object as a sort of map and use the first item in an array as the key. Then you can convert it back to an Array using Object.entries(). Like so:
const formatBids =
[
[4444, 10000],
[4444, 500],
[4455, 500],
];
const totals = {}
for (const bid of formatBids) {
totals[bid[0]] = (totals[bid[0]] || 0) + bid[1];
}
console.log("as object:", totals, "as array:", Object.entries(totals));