Created a function that creates a table and passed it an array, then created 2 inputs and a button. How to set an array by writing its input values after which clicking on the button worked.
function createTable(tableData) { var table = document.createElement('table'); var tableBody = document.createElement('tbody'); tableData.forEach(function(rowData) { var row = document.createElement('tr'); rowData.forEach(function(cellData) { var cell = document.createElement('td'); cell.appendChild(document.createTextNode(cellData)); row.appendChild(cell); }); tableBody.appendChild(row); }); table.appendChild(tableBody); document.body.appendChild(table); } var a = [["0", "0", "0",], ["0", ,"0", "0"]]; createTable(a); body { margin-top:10%; margin-left:40%; } th,td { width: 50px; border: 1px solid red; font-size:x-large; color:white; } tbody { background-color:blue; } input{ width:20px; height:20px; } <input type="text" class="col1"> <input type="text" class="col2"> <button class="btn">Go</button>