title: How can I populate a table with JavaScript?
body: <p>How can I populate a table with JavaScript in the proper way?</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function loadTableData() {
  
    //0: Date
    //1: Name
  
    var row = document.getElementById("test");
  
    var x = row.insertCell(0);
    x.innerHTML = "10/17/2018";
  
    var x = row.insertCell(1);
    x.innerHTML = "john doe";
  
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;table id="myTable" class="table table-borderless table-striped table-earning"&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;date&lt;/th&gt;
        &lt;th&gt;file name&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr id="test"&gt;&lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;script&gt;loadTableData();&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>My current code populates the first two cells but I would like to move to the next column and populate another two cells. Im not sure how to do this the correct way.</p>
  <p>Current output
  <a href="https://i.stack.imgur.com/hnInb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hnInb.png" alt="enter image description here" /></a></p>