Summing a 2D array by "group"
<p>I have an array in the form</p>
<pre><code>[
['16-24', 192081],
['16-24', 94452],
['16-24', 1055],
['25-34', 192081],
['25-34', 94452],
['25-34', 1055],
...
]
</code></pre>
<p>I have many items in the array that I'd like to reduce down to the unique left-hand entries. This is an example of what I'd like to reduce down to</p>
<pre><code>[
['16-24', 287588],
['25-34', 287588],
...
]
</code></pre>
<p>Obviously the numbers here are a contrived example. I've looked into JavaScript's array reduce, but how can I use it to achieve this effect?</p>