for loop table javascript code example
Example 1: Javascript looping through table
var table = document.getElementById("myTable");
for (let i in table.rows) {
let row = table.rows[i]
for (let j in row.cells) {
let col = row.cells[j]
}
}
Example 2: javascript forloop table
function get_table(data) {
let result = ['<table border=1>'];
for(let row of data) {
result.push('<tr>');
for(let cell of row){
result.push(`<td>${cell}</td>`);
}
result.push('</tr>');
}
result.push('</table>');
return result.join('\n');
}