You need to use
insertRow()[
^] to insert rows into your table.
<table>
<thead>
<tr>
<th>Year</th>
<th>Amount</th>
</tr>
</thead>
<tbody id="tableBody">
</tbody>
</table>
function appendRow(yearNumber, amount){
const tbody = document.getElementById("tableBody");
const tr = tbody.insertRow();
let td = tr.insertCell();
let text = document.createTextNode(yearNumber);
td.appendChild(text);
td = tr.insertCell();
text = document.createTextNode(amount);
td.appendChild(text);
}
Demo[
^]