title: Combinig array values with underscore.js
body: <p>I managed to do a coffescript map reduce to get out of the database what i need.</p>
  
  <pre><code>    inputarray = _.map  _.groupBy(inputarrayz, 'Price'), (v, k) -&gt; 
          {Price: k, 
          Money_Amount: _.reduce(v, ((m, i) -&gt; m + i['Money_Amount']), 0), 
          Product_Amount: _.reduce(v, ((m, i) -&gt; m + i['Product_Amount']), 0)}
      sorted = _.sortBy inputarray,"Price"
      return sorted
  </code></pre>
  
  <p>I have a table with the sorted result like this</p>
  
  <p>Price / Money / Product</p>
  
  <p>1 / 2 / 2</p>
  
  <p>2 / 10 / 5</p>
  
  <p>3 / 9 / 3</p>
  
  <p>where product amount is money divided by price.
  Now i want to have a fourth column to get the combined product count, starting with the first row and counting down. 
  Example:</p>
  
  <p>1 / 2 / 2 / 2 (only 2 products)</p>
  
  <p>2 / 10 / 5 / 7 (5+ the 2 before)</p>
  
  <p>3 / 9 / 3 / 12 (all before + 3)</p>
  
  <p>I tried to do it in jquery cause my head starts to explode when im thinking about map reduce...what resulted in some weird table row before add construct.
  hope someone could help me out.</p>
  
  <p>Thanks alot.</p>