title: Flatten an nested array of objects using Lodash
body: <p>My object looks like this:</p>
  
  <pre><code>const features = [{
                    'name': 'feature1', 'tags':
                    [{'weight':10, 'tagName': 't1'},{'weight':20, 'tagName': 't2'}, {'weight':30, 'tagName': 't3'}]
                    },
                    {
                    'name': 'feature2', 'tags':
                    [{'weight':40, 'tagName': 't1'}, {'weight':5, 'tagName':'t2'}, {'weight':70, 'tagName':'t3'}]
                    },
                    {
                    'name': 'feature3', 'tags':[
                    {'weight':50, 'tagName': 't1'}, {'weight':2, 'tagName': 't2'}, {'weight':80, 'tagName': 't3'}]
                   }]
  </code></pre>
  
  <p>I would like my output to look something like this:</p>
  
  <pre><code>const features = [{'name':'feature1', 'weight':10, 'tagName':'t1'}, 
                    {'name':'feature1', 'weight':20, 'tagName':'t2'}, ...
                    {'name':'feature3', 'weight':80, 'tagName':'t3'}]
  </code></pre>
  
  <p>I tried to <code>merge</code> and the <code>flatten</code> but it does not work. </p>
  
  <p><strong>Update 1</strong>
  I tried this:</p>
  
  <pre><code>let feat = features;
  
  results = []
  
  _.each(feat, (item) =&gt; { 
                          console.log(item);
                          results.push(_.flatten(_.pick(item.tags, 'weight'))); // pick for certain keys. 
                         }
  </code></pre>
  
  <p><strong>Update 2</strong>
  This solved my problem</p>
  
  <pre><code>_.each(features, (item) =&gt; { 
    _.each(item.tags, (itemTag) =&gt; { 
      results.push({'name':item.name, 'weight':itemTag.weight, 'tagName':itemTag.tagName})})})
  </code></pre>
  
  <p>But I want to know if there is a more <code>lodash</code> way to do this!</p>