title: Filter Object based on Keys and compare with array
body: <p>I currently have an object containing key with multiple values.</p>
  <p>I also have an array containing a simple key check i.e. <code>[&quot;random&quot;, &quot;three&quot;]</code>.</p>
  <p>I want to return mainData but only with the object and the data from whats in the array i.e. <code>[&quot;random&quot;, &quot;three&quot;]</code></p>
  <p><strong>Current Code:</strong></p>
  <pre><code>const mainData = {
      random: {
          name: &quot;Random Entity&quot;,
          date: &quot;05/04/2022&quot;,
          startTime: &quot;19:00&quot;,
          finishTime: &quot;00:00&quot;,
      },
      one: {
          name: &quot;One Entity&quot;,
          date: &quot;16/04/2022&quot;,
          startTime: &quot;16:00&quot;,
          finishTime: &quot;20:00&quot;,
      },
      three: {
          name: &quot;Three Entity&quot;,
          date: &quot;19/04/2022&quot;,
          startTime: &quot;10:00&quot;,
          finishTime: &quot;11:00&quot;,
      },
  };
  
  export default mainData;
  </code></pre>
  <p><strong>Desired Output</strong></p>
  <pre><code>const mainData = {
      random: {
          name: &quot;Random Entity&quot;,
          date: &quot;05/04/2022&quot;,
          startTime: &quot;19:00&quot;,
          finishTime: &quot;00:00&quot;,
      },
      three: {
          name: &quot;Three Entity&quot;,
          date: &quot;19/04/2022&quot;,
          startTime: &quot;10:00&quot;,
          finishTime: &quot;11:00&quot;,
      },
  };
  </code></pre>
  <p><strong>Attempt:</strong></p>
  <pre><code>let filterKey = 'random';
  const result = Object.entries(mainData).filter(([k, v]) =&gt; k== filterKey);
  </code></pre>
  <p>This works only as a single search, not an array search.</p>