Hello,
I’m trying to add a button at the end of the table but in my case it seems to add 2 buttons in the table/cell, one with caption and one thats empty.
any ideas as to whats happening?
and what is this code doing: <TD> == $0?

<script>
var person = [{irstName:"John", lastName:"Doe", age:46},
{firstName:"jack1", lastName:"jack2", age:47},
{firstName:"Steve1", lastName:"Steve2", age:48}];
var legArray = person.length;
var divTest = document.getElementById("testTable");
// var divTest = document.getElementsByTagName("#testTable");
var tbl = document.createElement("table");
var tblBody = document.createElement("tbody");
person.forEach(function(value) {
var row = document.createElement("tr");
for (var o in value) {
// console.log(value[o]);
//var newTodo.textContent = 'Do homework';
var cell = document.createElement("td");
var cellText = document.createTextNode(value[o]);
cell.appendChild(cellText);
row.appendChild(cell);
}
var newBtn = document.createElement('td');
newBtn.innerHTML = "<button type='submit' value='test'> button <button>";
row.appendChild(newBtn);
tblBody.appendChild(row);
console.log(tblBody);
});
tbl.appendChild(tblBody);
divTest.appendChild(tbl);
tbl.setAttribute("border", "2");
</script>