title: Filter Array Of Objects Based On Dictionary in React
body: <p>I am new to UI stuff. I know how to do this c#. I have a dictionary named CarValues in my code which contains following data:</p>
  
  <pre><code>dictionary: CarValues
  
  key ==&gt; string
  
  Value ==&gt; Array
  
  1. key =&gt; Honda,
     Value =&gt; white, yellow
  2. Key =&gt; Volkswagen 
     Value =&gt; 123, 456
  3. key =&gt; Mercedes
     Value =&gt; E, A, B
  </code></pre>
  
  <p>I have one more array with objects like below</p>
  
  <p>Car Objects:</p>
  
  <pre><code>Cars = [
  {
    Toyota: White
    Mercedes: B
    Honda: Red
    Volkswagen: 456
  },
  {
    Toyota: Green
    Mercedes: Z
    Honda: Blue
    Volkswagen: 234
  },
  {
    Toyota: Black
    Mercedes: A
    Honda: Yellow
    Volkswagen: 789
  },
  {
    Toyota: White
    Mercedes: B
    Honda: Red
    Volkswagen: 456
  },
  {
    Toyota: Green
    Mercedes: Z
    Honda: Blue
    Volkswagen: 234
  },
  {
    Toyota: Grey
    Mercedes: M
    Honda: Orange
    Volkswagen: 394
  }
  .............
  .............
  ]
  </code></pre>
  
  <p>I want to filter out objects from Cars that matches Car Values.
  Iterate through the keys of Cars and see if the values are present in Car Values.</p>
  
  <pre><code>The output should be something like below:
  
  {
    Toyota: White
    Mercedes: B
    Honda: Red
    Volkswagen: 456
  },
  {
    Toyota: Black
    Mercedes: A
    Honda: Yellow
    Volkswagen: 789
  }
  </code></pre>
  
  <p>I was doing something like</p>
  
  <pre><code>    var copyCars= [];
  
      Object.entries(this.state.carValues).forEach(function (key) {
          Object.entries(this.state.carValues[key]).forEach(function (value) {
              var filterData = this.state.cars.filter(x =&gt; x[key] == value);
              copyCars.push(filterData);
          })            
      });
  </code></pre>
  
  <p>But I am getting error at this line as of now saying this is undefined.
      var filterData = this.state.cars.filter(x => x[key] == value);</p>