title: take information from an array and load it to a table
body: <p>thanks for reading my post!</p>
  <p>I've been trying to create a function that will take the objects in an array of employee data and display them in a table.</p>
  <p>Within the class called 'system', I have system.giveAllEmployees(), which returns the array of all the employees, while system.giveAllOffers() returns all the active offers that have been put in the system. It should all be organized in the table employeeData, and run through and see how many offers each employee is assigned to, and add that to the table as well. It works and loads to the table but instead of updating the offer for each employee, whenever a new offer is loaded to the system it updates the offer number for all the employees in the table.</p>
  <p>I assume this is because of how i set up the loop? but i'm really stumped as to why this is happening. I can provide any other information or code needed, if anyone knows a better way to load data from arrays into a table id appreciate that as well!</p>
  <pre class="lang-js prettyprint-override"><code>function loadAll() {
    var a      = system.giveAllEmployees();
    var b      = system.giveAllOffers();
    var tr     = &quot;&quot;;
    var table  = document.getElementById(&quot;employeeData&quot;);
    let offers = 0;
    
    table.innerHTML = &quot;&quot;;
  
    a.forEach( x =&gt; {   
      b.forEach( y =&gt; {
        if (x.employeeName === y.name) {
          offers += 1;
        }
        return offers;
      }),
      tr += '&lt;tr&gt;';
      tr += '&lt;td&gt;' + x.name + '&lt;/td&gt;' 
          + '&lt;td&gt;' + x.document + '&lt;/td&gt;' 
          + '&lt;td&gt;' + x.departament + '&lt;/td&gt;'
          + '&lt;td&gt;' + x.age + '&lt;/td&gt;' 
          + '&lt;td&gt;' + offers + '&lt;/td&gt;';
      tr += '&lt;/tr&gt;';
      offers = 0;
    })
    table.innerHTML += tr;
  }
  </code></pre>
  <p>And for context, here's a picture of the table the data is loaded into:</p>
  <p><a href="https://i.stack.imgur.com/Cmo63.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Cmo63.png" alt="Table" /></a></p>
  <p>Thanks again for any tips or help on this issue!</p>