title: Better usage of _.each by using _.reduce
body: <p>I have the need to extract data form an existing array, to filter only year and <code>reference_id</code> for every item where quantity is <code>&gt; 0</code>.</p>
  
  <p>My <code>sample_array</code> contains this data :</p>
  
  <pre><code>var sample_array = [{
      'reference_id': 1,
      'products': [{
          year: 1,
          quantity: 0
      }, {
          year: 2009,
          quantity: 5
      }]
  }, {
      'reference_id': 2,
      'products': [{
          year: 2009,
          quantity: 0
      }]
  }, {
      'reference_id': 3,
      'products': [{
          year: 1,
          quantity: 0
      }, {
          year: 2009,
          quantity: 5
      }]
  }, {
      'reference_id': 4,
      'products': [{
          year: 2014,
          quantity: 10
      }, {
          year: 2015,
          quantity: 6
      }]
  }];
  </code></pre>
  
  <p>To let me extract the way I need my data, I used twice <code>_.each</code> (I'm still using <em>underscore.js</em> on few projects) to filter first, then to rebuild an array with the <code>year</code> and the <code>reference_id</code>.</p>
  
  <pre><code>var references = [];
  
  _.each(sample_array, function(reference) {
      reference_products = _.filter(reference.products, function(data) {
          return data.quantity &gt; 0;
      });
      if (!_.isEmpty(reference_products))
          _.each(reference_products, function(product) {
              references.push({
                  'reference_id': reference.reference_id,
                  'year': product.year
              });
          });
  });
  </code></pre>
  
  <p>It works without any problems, but I think it may exists a more elegant way to build my array references, buy using <code>_.reduce</code> but I didn't found the way to achieve it.</p>
  
  <p>Expected results would be for <code>console.log(references)</code>:</p>
  
  <pre><code>[{
      reference_id: 1
      year: 2009
  } {
      reference_id: 3
      year: 2009
  } {
      reference_id: 4
      year: 2014
  } {
      reference_id: 4
      year: 2015
  }]
  </code></pre>
  
  <p>Any tips ?</p>