title: How to push all key/value pairs to object from forEach
body: <p>I'm running my array of objects (this.state.exportEntries) through a for loop that is then comparing the itemId to the key within the object returned within the for loop. If the key matches itemId, then run a forEach to push that key/value to the filteredData object.</p>
  <p>My issue is that, if I have more than one value that matches, the forEach only pushes the last returned value to the filteredData object.</p>
  <p>Could anyone help me understand how to push all returned values to the filteredData object? As you can see in the output of this.state.filteredData, only the last key/value pair that is matched gets pushed to filteredData.</p>
  <p><strong>Code Structure</strong></p>
  <pre><code>for (let item of this.state.exportEntries) {
  
    console.log(item);
  
    Object.entries(item)
      .filter(([key,]) =&gt; key === itemId)
      .forEach(([key, value]) =&gt; (this.state.filteredData[key] = value));
  
  }
  
  console.log(this.state.filteredData);
  </code></pre>
  <p><strong>Output of item</strong></p>
  <pre><code>{1.2: &quot;1&quot;, 1.3: &quot;1&quot;}
  
  {1.2: &quot;2&quot;, 1.3: &quot;2&quot;}
  
  {1.2: &quot;3&quot;, 1.3: &quot;3&quot;}
  
  {1.2: &quot;4&quot;, 1.3: &quot;4&quot;}
  </code></pre>
  <p><strong>Output of this.state.filteredData</strong></p>
  <pre><code>{1.3: &quot;4&quot;}
  </code></pre>
  <p><strong>Desired Result</strong></p>
  <pre><code>{
   1.3: &quot;1, 2, 3, 4&quot;
  }
  </code></pre>