title: Using JavaScript, how can I filter an array of objects using multiple criteria in a child object
body: <p>I want to get all the customers who have returned product &quot;2&quot;:</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>// Note that in production this array is much longer
  const customers = [
    {
      "customerId": "1",
      "products": [
        {
          "productId": "1",
          "status": "purchased"
        },
        {
          "productId": "2",
          "status": "purchased"
        }
      ]
    },
    {
      "customerId": "2",
      "products": [
        {
          "productId": "1",
          "status": "purchased"
        },
        {
          "productId": "2",
          "status": "returned"
        }
      ],
    }
  ]
  const returns = customers.filter((customer) =&gt;
    customer.products.some((product) =&gt; product.productId === "2" &amp;&amp; product.status === "returned")
  );
  console.log(returns);</code></pre>
  </div>
  </div>
  </p>
  <p>I thought my use of <code>filter</code> would work - but I am guessing some() doesn't work with multiple criteria? Or am I doing something else wrong? Or is there a better way?</p>