title: Add button to dynamic html table javascript
body: <p>I'm new to dynamic javascript and I'm adding a button to my dynamic HTML table. </p>
  
  <pre><code>function addToTable(){
  
      var table = document.getElementById("table");
      var row = table.insertRow(counter + 1);
  
      var removeRow=document.createElement("BUTTON");
  
      var cell0 = row.insertCell(0)
      var cell1 = row.insertCell(1);
      var cell2 = row.insertCell(2);
      var cell3 = row.insertCell(3);
  
      cell0.innerHTML = counter + 1;
      cell1.innerHTML = getName(array[counter]); 
      cell2.innerHTML = getEmail(array[counter]);
      cell3.innerHTML = document.body.appendChild(removeRow);
  
      counter++;
  }
  </code></pre>
  
  <p>Whenever I run this, in the first the cells I get the index number, the name, and the email. in the 4th cell it prints "[object HTMLButtonElement]".</p>
  
  <p>And an addition issue is when I assign a label on the button the entire method doesn't work. This is how I was adding a label.</p>
  
  <pre><code>var removeRow=document.createElement("BUTTON");
  var text=document.createTextNode("Remove");
  btn.appendChild(text);
  document.body.appendChild(removeRow);
  </code></pre>