title: How to filter an array by multiple (all) of some object's values?
body: <p>In the below code, I am trying to reduce the <code>persons</code> array only to persons which match perfectly with <code>filters</code> object.</p>
  
  <p>Currently the output is an array of objects that have a match in ANY of the object keys. How can I adjust it to return only the second person - the one that has a perfect match with ALL filters?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var persons = [
   {city: 'London', 'age': 18, 'name': 'Josh'},
   {city: 'London', 'age':42, 'name': 'Josh'},
   {city: 'New York', 'age': 42, 'name': 'Mike'},
   {city: 'Tokyo', 'age': 33, 'name': 'Kazuna'},
  ]
  
  var filters = {
   city: 'London',
   age: 42,
   name: 'Josh',
  }
  
  function filter(person){
   for (let key of Object.keys(filters)) {
    if (person[key] == filters[key]) {
     return person
    }
   }
  }
  
  var filtered = persons.filter((person) =&gt; filter(person))
  console.log(filtered)</code></pre>
  </div>
  </div>
  </p>