I'm trying to make a table with 2 columns, the header is for Names and Salaries, then i'm trying to loop an array with names and another one for salaries, but it doesn't come out in order, they fill the first column only(Name)
<table border="1">
<thead>
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<script>
var employeeName = ["Tom", "John", "Jack", "Sam", "Sarah", "Rachel", "Rick", "Sean", "Joe"];
for(var i = 0 ; i < employeeName.length ; i++)
{
document.write("<tr>");
document.write("<td>" + employeeName[i] + "</td>");
}
var employeeSalary = ["1000", "1500", "2000", "5000", "2500", "3000", "3500", "2500", "1750"];
for(var e = 0 ; e < employeeSalary.length ; e++)
{
document.write("<td>" + employeeSalary[e] + "</td>");
document.write("</tr>");
}
</script>
</tbody>
</table>
document.writeif you can. You should get a reference to thetbodyelement, build the complete string, then usinginnerHTMLto add that string as the content of thetbody