SO I have 2 arrays which are
var num = ["1", "2", "3"];
var cars = ["Saab", "Volvo", "BMW"];
and I made a button where it'll add rows and column and place the values of my 2 arrays in the table. HoweverIdon't know how to make it into a 2d array and display it on my table.
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var table = document.getElementById("myTable");
var row;
var t = [][];
var num = ["1", "2", "3"];
var cars = ["Saab", "Volvo", "BMW"];
for (i = 0; i < num.length;i++){
var row = table.insertRow(i);
for (x = 0; x < cars[i].length;x++){
var cell1 = row.insertCell(x);
after this part i don't know what to do and it doesn't work. How can I combine the arrays and make it display it in the table for eg(t[0][0] would be 1 saab)
*cars[i] = num[x];
cell1.innerHTML = cars[i][x];*
}
}
}