Sorry if the title isn't that clear. This is kind of hard to explain for me, as I'm not that good when it comes to multiple arrays.
I have an array: [ [21, 1000], [21, 500], [18, 100], [18, 200] ]
Now I want to get this resulting array: [ [21, 1500], [18, 300] ]
How do I go about doing this?
I've tried using 21 and 18 as array keys, but this way I couldn't use the array in a for loop with .length counting. I ended up with a total of 4 arrays to almost get it working.
Edit:
I want to avoid using the 21 and 18 values as array keys.
I also want to be able to iterate over the resulting array/object, and use the 21 and 18 "keys" as well, to make some further changes to my page.
Thanks already for all the responses!
forbut you can actually use.each()for object.