Here is an error:
Uncaught TypeError: Cannot read property 'appendChild' of null
The example of code:
function MakeTable(Matrix){
var newElem = document.createElement('table');
newElem.border = "1px";
for(var j = 0; j < Matrix.length; j++) {
var newRow = newElem.insertRow(j);
for(var n = 0; n < Matrix[j].length; n++) {
var newCell = newRow.insertCell(n);
newCell.innerText = Matrix[j][n];
}
}
document.getElementById('table1').appendChild(newElem);
}
table1element isn't found in the DOM.<head>and it isn't using a delay to make sure it doesn't run when until the DOM is loaded, then it'll run before the element exists. Move your script to just before the closing</body>tag.Matrixyou are passing through toMakeTable()? An object, array etc?