title: Underscore.js: Sum of items in a collection
body: <p>I made a small plnkr <a href="http://plnkr.co/edit/B5HGxhwvWsfvOR97z7TL?p=preview" rel="noreferrer">here</a> to show what I am trying to achieve. I have a big dataset, where I like to sum the individual type to get a total.</p>
  
  <p>I could think of iterating and adding the results to an object hash, but wonder more elegant way to solve it with underscore. I am using underscore.js, but never tried map reduce or other functional paradigm. Please update the plnkr to learn how to do this.</p>
  
  <p><a href="http://plnkr.co/edit/B5HGxhwvWsfvOR97z7TL?p=preview" rel="noreferrer">http://plnkr.co/edit/B5HGxhwvWsfvOR97z7TL?p=preview</a></p>
  
  <pre><code>var data = [ {'type': "A", 'val':2},
    {'type': "B", 'val':3},
    {'type': "A", 'val':1},
    {'type': "C", 'val':5} ];
  
  
   _.each(data, function (elm, index) {
     console.log(elm);  
   });
  
   /*
   Desired output
  
   out = [ {'type': "A", 'total':3},
    {'type': "B", 'total':3},
    {'type': "C", 'total':5} ];
  
   */
  </code></pre>