title: Compare Object value with array?
body: <p>I want to compare the object with the given array, the object that I am using is mentioned below</p>
  <pre><code>var table = { api_key: &quot;1234&quot;, data: [{ temperature: 100, humidity: 200 }] };
  </code></pre>
  <p>The array that I used is mention below :</p>
  <pre><code>var key = [ '1234', '3456' ]
  </code></pre>
  <p>the code that is used to return the object when the values of array and object api_key is equal mention below</p>
  <pre class="lang-js prettyprint-override"><code>const value = key.filter(val =&gt; {
        if(table.api_key === val){
       console.log({table})
       return [table];
       }
     }); 
  </code></pre>
  <p>but when I use that code am not getting the return value of that given object. How to return the object when the array value and object api_key values are same</p>
  <p>I want to return the same object when condition satisfies example output:</p>
  <pre><code>{ api_key: &quot;1234&quot;, data: [{ temperature: 100, humidity: 200 }] };
  </code></pre>
  <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 table = { api_key: "1234", data: [{ temperature: 100, humidity: 200 }] };
  var key = [ '1234', '345' ]
  
   const value = key.filter(val =&gt; {
        if(table.api_key === val){
       console.log({table})
       return [table];
       }
     }); 
     
     console.log({value})</code></pre>
  </div>
  </div>
  </p>