title: Javascript add 2nd array values together if first values are the same
body: <p>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.</p>
  
  <p>I have an array: <code>[ [21, 1000], [21, 500], [18, 100], [18, 200] ]</code></p>
  
  <p>Now I want to get this resulting array: <code>[ [21, 1500], [18, 300] ]</code></p>
  
  <p>How do I go about doing this?</p>
  
  <p>I've tried using 21 and 18 as array <strong>keys</strong>, but this way I couldn't use the array in a <code>for</code> loop with <code>.length</code> counting. I ended up with a total of 4 arrays to almost get it working.</p>
  
  <hr>
  
  <p><strong>Edit:</strong></p>
  
  <p>I want to avoid using the 21 and 18 values as array keys.</p>
  
  <p>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.</p>
  
  <p>Thanks already for all the responses!</p>