I am having issues inserting values from an object into a dynamically generated HTML table.
Find below my simple HTML code:
<table id="table" border="1">
<tr>
<th>Number</th>
<th>Amount</th>
<th>Status</th>
</tr>
</table>
I am dynamically populating the table above using values from an object. The object is generated from saved values in the localStorage.
Find inline my javascript code along with my comments and explanation:
var array = JSON.parse(localStorage.getItem('transactionData'));
console.log(array);
The console.log(array) as seem above, correctly yields:
table = document.getElementById("table");
for(var i = 0; i < array.length; i++)
{
console.log("Number of transactions: " +array.length);
var newRow = table.insertRow(table.length);
var x;
for (x in array)
{
var cell = newRow.insertCell(x);
cell.innerHTML += array[x].payersNumber;
}
}
My main issue seems to be within the scope of the second for-loop. I'd like for the code here to populate every row in the table with (in this order) the Number, Amount then finally the Status.
The code in the second for-loop above erroneously fills in every cell in the table with phone numbers, and also adds additional columns as seen in the image below
Kindly help me understand how I can correctly formulate my code to populate every row with the Number, Amount and the Status values from the object.
Looking forward to your help.

