title: Filter array of objects on key from array of values JavaScript
body: <p>I have an array of objects [{...}, {...}] with 2 objects inside. I would like to filter them with values from an array using JavaScript. The inital object could be any length from 1 to n. I think I need to filter on the key from the json data in a loop using .includes()</p>
  <p>This is a mess but I think this needs to be inside another loop for the length of jsonData</p>
  <pre><code>          for (i=0; i&lt;finalArray.length; i++){
              jsonData= Object.fromEntries(Object.entries(jsonData).filter(([key, value]) =&gt; key.includes(finalArray[i])) )
            }
  </code></pre>
  <pre><code>0: { &quot;cbsa_cde&quot;: &quot;33460&quot;, &quot;cbsa_nm&quot;: &quot;Minneapolis-St. Paul-Bloomington, MN-WI&quot;, &quot;countycode&quot;: &quot;27053&quot;, &quot;hh_50k_100k_201612&quot;: 71, &quot;hh_50k_100k_201706&quot;: 86, &quot;hh_50k_100k_201712&quot;: 60, &quot;hh_50k_100k_201806&quot;: 37, &quot;hh_50k_100k_201812&quot;: 49, &quot;hh_50k_100k_201906&quot;: 35, &quot;hh_50k_100k_201912&quot;: 38, &quot;hh_50k_100k_202006&quot;: 46, &quot;hh_50k_100k_202012&quot;: 58, &quot;hh_100k_250k_201612&quot;: 120, &quot;hh_100k_250k_201706&quot;: 121, &quot;hh_100k_250k_201712&quot;: 153, &quot;hh_100k_250k_201806&quot;: 126, &quot;hh_100k_250k_201812&quot;: 126, &quot;hh_100k_250k_201906&quot;: 125, &quot;hh_100k_250k_201912&quot;: 120, &quot;hh_100k_250k_202006&quot;: 99, &quot;hh_100k_250k_202012&quot;: 84}   
  
  1: { &quot;cbsa_cde&quot;: &quot;33460&quot;, &quot;cbsa_nm&quot;: &quot;Minneapolis-St. Paul-Bloomington, MN-WI&quot;, &quot;countycode&quot;: &quot;27053&quot;,&quot;hh_50k_100k_201612&quot;: 20, &quot;hh_50k_100k_201706&quot;: 33, &quot;hh_50k_100k_201712&quot;: 22, &quot;hh_50k_100k_201806&quot;: 41, &quot;hh_50k_100k_201812&quot;: 52, &quot;hh_50k_100k_201906&quot;: 45, &quot;hh_50k_100k_201912&quot;: 40, &quot;hh_50k_100k_202006&quot;: 41, &quot;hh_50k_100k_202012&quot;: 50, &quot;hh_100k_250k_201612&quot;: 99, &quot;hh_100k_250k_201706&quot;: 108, &quot;hh_100k_250k_201712&quot;: 130, &quot;hh_100k_250k_201806&quot;: 84, &quot;hh_100k_250k_201812&quot;: 90, &quot;hh_100k_250k_201906&quot;: 97, &quot;hh_100k_250k_201912&quot;: 89, &quot;hh_100k_250k_202006&quot;: 95, &quot;hh_100k_250k_202012&quot;: 87}   
  </code></pre>
  <p>The array I would like to use as a filter</p>
  <pre><code>FilterArray = [ &quot;HH_50K_100K_201612&quot;, &quot;HH_50K_100K_201706&quot;, &quot;HH_100K_250K_201612&quot;, &quot;HH_100K_250K_201706&quot; ]
  </code></pre>
  <p>Final output would be best if it modifies the original.</p>
  <pre><code>jsonData= 
  0: {&quot;hh_50k_100k_201612&quot;: 71, &quot;hh_50k_100k_201706&quot;: 86, &quot;hh_100k_250k_201612&quot;: 120, &quot;hh_100k_250k_201706&quot;: 121}   
  
  1: {&quot;hh_50k_100k_201612&quot;: 20, &quot;hh_50k_100k_201706&quot;: 33, &quot;hh_100k_250k_201612&quot;: 99, &quot;hh_100k_250k_201706&quot;: 108}
  </code></pre>