I want to write some JavaScript to create a simple HTML table from an array that just contains numbers:
var array = [1,2,3,4,5,6,7,8,9,10];
You could iterate the array and build a new row if the remainder with 5 is zero.
var array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
tr;
array.forEach((v, i) => {
var td = document.createElement('td');
if (!(i % 5)) {
tr = document.createElement('tr');
document.getElementById('table0').appendChild(tr);
}
td.appendChild(document.createTextNode(v));
tr.appendChild(td);
});