title: how to filter array object using object property
body: <p>I got an array of object </p>
  
  <pre><code>    const devices = [{
      deviceLocation: {
        label: "Pure",
        value: "pure"
      },
      deviceName: "test7"
      devicePaymentMethods: [{
        label: "ab",
        value: "ab"
      } {
        label: "cd",
        value: "cd"
      } {
        label: "ef",
        value: "ef"
      }]
      deviceType: "iPad"
      id: "001"
      connected: false
      enabled: false
    },
  
    {
      deviceLocation: {
        label: "kandy",
        value: "kandy"
      },
      deviceName: "test4"
      devicePaymentMethods: [{
        label: "ab",
        value: "ab"
      } {
        label: "cd",
        value: "cd"
      }]
      deviceType: "iPad"
      id: "004"
      connected: false
      enabled: false
    }
  ]
  </code></pre>
  
  <p>I want to filter the array by object using <code>deviceName</code>,<code>deviceLocation</code> and <code>devicePaymentMethods</code></p>
  
  <p>Here is what I have already done and it is working for <code>deviceName</code> and <code>deviceLocation</code>  but doesn't work for <code>devicePaymentMethods</code></p>
  
  <pre><code>const filterByValue = (array, string) =&gt; {
  return array.filter(o =&gt;
    Object.keys(o).some(k =&gt; {
      if (k === "deviceName") {
        return o[k].toLowerCase().includes(string.toLowerCase());
      } else if (k === "deviceLocation") {
        return o[k].label.toLowerCase().includes(string.toLowerCase());
      } else if (k === "devicePaymentMethods") {
         o[k].map(pay =&gt; {
            if(pay.label.toLowerCase().includes(string.toLowerCase()))
          return pay;
        });
      }
    })
  );
  };
  
   filterByValue(devices, "ab")
  </code></pre>