title: Filter Objects of Array of Objects using lodash
body: <p>I have a <em>Objects of an array of objects</em> as given below. I am trying to filter out each object within the array where is <strong>quantity is greater than 0</strong> and drop it in a new variable. So via <code>lodash</code> I tried to use <code>_.filter</code> within <code>_.(myArr).forEach</code>. But this always returns an empty array. The console.log within <code>_.filter</code> shows <code>quantity</code> as it is but it doesn't return any value based on the condition. Am I using it in a proper way here or is there any other way I can use this to filter out?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var data = [
    [{
      "aid": "1",
      "desc": "Desc 1",
      "name": "Name 1",
      "quantity": 1
    }, {
      "aid": "2",
      "desc": "Desc 2",
      "name": "Name 2",
      "quantity": 1
    }, {
      "aid": "3",
      "desc": "Desc 3",
      "name": "Name 3",
      "quantity": 0
    }],
    [{
      "aid": "4",
      "desc": "Desc 4",
      "name": "Name 4",
      "quantity": 0
    }, {
      "aid": "5",
      "desc": "Desc 5",
      "name": "Name 5",
      "quantity": 1
    }],
    [{
      "aid": "6",
      "desc": "Desc 6",
      "name": "Name 6",
      "quantity": 0
    }, {
      "aid": "7",
      "desc": "Desc 7",
      "name": "Name 7",
      "quantity": 0
    }]
  ];
  
  var filtered;
  _(data).forEach((d) =&gt; {
    filtered = _.filter(d, (o) =&gt; {
      return o.quantity &gt; 0;
    });
  });
  
  console.log(filtered);</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.14.0/lodash.min.js"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>