There is such an array:
[{ id: 100, chance: 10 }, { id: 100, chance: 30 }, { id: 200, chance: 10 }, { id: 300, chance: 5 }, { id: 200, chance: 30 }, { id: 100, chance: 15 } ] How to make a loop so that it returns like this:
id:100 chance: 55 (10+30+15 выводить не надо) id:200 chance: 40 (10+30 выводить не надо) id:300 chance: 5 It is necessary for the cycle to add chance for objects with the same id