title: How to filter array of objects in React
body: <p>I have an array of timeseries objects that I need to filter in React. 
  Specifically, I need to return an array containing a filtered subset of the array of objects, based on the value of <code>device_id</code> being equal to e.g. <code>7F34B296</code>.</p>
  
  <p>The raw array looks as below:</p>
  
  <pre><code>[
      {
          "label": "time_stamp",
          "data": [
              "2019-04-17 21:01:25.673949957+02:00",
              "2019-04-17 21:01:30.673949957+02:00",
              "2019-04-17 21:01:35.673949957+02:00",
              "2019-04-17 21:01:40.673949957+02:00",
              "2019-04-17 21:01:45.673949957+02:00"
          ]
      },
      {
          "label": "device_id",
          "data": [
              "7F34B296",
              "7F34B296",
              "7F34B296",
              "AB22438D",
              "AB22438D"
          ]
      },
      {
          "label": "parameter_x",
          "data": [
              "929.1965116",
              "927.5152582",
              "928.7476077",
              "1919.2691327",
              "1918.7047619"
          ]
      }
  ]
  </code></pre>
  
  <p>The intended output array (after filtering) looks as below:</p>
  
  <pre><code>[
      {
          "label": "time_stamp",
          "data": [
              "2019-04-17 21:01:25.673949957+02:00",
              "2019-04-17 21:01:30.673949957+02:00",
              "2019-04-17 21:01:35.673949957+02:00"
          ]
      },
      {
          "label": "device_id",
          "data": [
              "7F34B296",
              "7F34B296",
              "7F34B296"
          ]
      },
      {
          "label": "parameter_x",
          "data": [
              "929.1965116",
              "927.5152582",
              "928.7476077"
          ]
      }
  ]
  </code></pre>
  
  <p>I tried using various methods, including below - but I seem unable to get the desired result. I think I'm missing the part on how to handle that the filtering of the entire array of objects should depend on the value of a subset of one of the objects.</p>
  
  <pre><code>const filters = [
      {
        predicateFn: data =&gt; data.data == "7F34B296"
      }
    ];
  
    function getFilteredPersons(filters) {
      return datasets.filter(p =&gt; filters.every(filter =&gt; filter.predicateFn(p)));
    }
  
    console.log(getFilteredPersons(filters));
  </code></pre>