The key is in the three
for...each statements that we used. One loops through the array of table header strings, and appends a table cell (
td) element with each value into the
thead row. There are then two nested
.forEach() statements that do the same for each row in the body. We technically only have one row in the body right now, so probably didn't need that messy double
for...each, but now all we have to do to add another row to the table is simply append another data array to the
rows variable. We'll talk more about
Array.prototype.forEach and other array functions in the next chapter.
tableFactory function to do...