title: Filtering for Multiple Fields in Object Array in Javascript/Lodash
body: <p>I have the following array:</p>
  
  <p>PeopleList</p>
  
  <pre><code>[ {id:1, name:"Brian", status:"active"}, {id:2, name:"Mary", status:"active"},
    {id:3, name:"John", status:"pending"}, {id:4, name:"Steph", status:"pending"},
   {id:5, name:"Peter", status:"inactive"}
  ]
  </code></pre>
  
  <p>statusList</p>
  
  <pre><code>[ 'active', 'pending']
  </code></pre>
  
  <p>I want to filter the object array to only the statusList so I did the following:</p>
  
  <pre><code>var filteredPeople  =PeopleList.map(person =&gt; {
    for (var i=0; i&lt;=statusList.length; i++){
      if(statusList[i] == person.active)
          return {...person};
    }
  });
  </code></pre>
  
  <p>While the person objects return correctly, I also get "undefined" for objects that didn't pass the conditional statement. </p>
  
  <p>So my result is:</p>
  
  <pre><code>   [object, object, object,object, undefined ] 
  </code></pre>
  
  <p>How can I make it so that if the conditional does not pass, I remove that object from the list? </p>