Need help fixing an issue with a broken table that uses both 1 and 2 Dimensional Arrays along with for-loops.
Is there a way to ensure that "loanAmount[row]" is displayed only once in the leftmost column of the table?
function print2DArrayTable(this2DArray, title)
{
//Creates the header of the table
document.write("<table border='1' cellpadding='5'>");
document.write("<tr><th colspan='8'>");
document.write("<h2>" + title + "</h2>");
document.write("</th></tr>")
//Creates the Year headers on top of the table columns.
document.write("<th></th>");
for(x=0; x<numberOfYear.length; x++)
{
document.write("<th>" + numberOfYear[x] + "</th>");
}
for(row=0; row<this2DArray.length; row++)
{
document.write("<tr>");
for(col=0; col<this2DArray[0].length; col++)
{
document.write("<td>"+ loanAmount[row] +"</td>");
document.write("<td>");
document.write(this2DArray[row][col] + " ");
document.write("</td>");
}
document.write("</tr>");
}
document.write("</table>");
}/* end of print2DArraytable */
The first column displays correctly, but the following columns do not. Here is a snapshot of the issue: