Что то типа такого
<body>
<div class="slot" data-slot="1" data-age="20" data-sum="50"></div>
<div class="slot" data-slot="2" data-age="30" data-sum="40"></div>
<div class="slot" data-slot="1" data-age="20" data-sum="100"></div>
<div class="slot" data-slot="1" data-age="20" data-sum="70"></div>
<div class="slot" data-slot="2" data-age="30" data-sum="60"></div>
<script>
const slot = [...document.querySelectorAll('.slot')];
const map = slot.reduce((map,el) =>{
const item = el.dataset.slot + '_' + el.dataset.age;
map[item] ??= +el.dataset.sum;
if (map[item] < +el.dataset.sum) map[item] = +el.dataset.sum;
return map;
}, {});
const arr = [];
for (const item in map) {
const [slot, age] = item.split('_');
arr.push({slot, age, sum: ''});
arr.push({slot, age, sum: map[item]});
}
console.log(arr);
</script>
</body>