title: JavaScript. Creating a dynamic table based on a user input
body: <p>I'm trying to ask the user through a prompt for a number that is an: integer, greater than 0, and is numeric. I did that with a do while loop and seems to be working correctly. With that number I have to pass it to the function called "genTable" and create a table with a dynamic amount of rows based on what the user typed. However, with my current code I can't seem to get the table to appear on the page. Any ideas on where I went wrong and how to fix it?</p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;jsLoopDemo&lt;/title&gt;
  
  &lt;!-- 
  Honor Code: I acknowledge that this code represents my own work: CC
  Date:  July 6, 2017
  --&gt;
  
  &lt;meta charset="utf-8" /&gt;
  &lt;meta name="description" content="Create a chart with rows based on a number 
  user chose." /&gt;
  &lt;meta name="keywords" content="loop, row, dynamic" /&gt;
  &lt;meta name="author" content="" /&gt;
  
  
  &lt;script type="text/javascript"&gt;
  
  
      do{
         var numChose = prompt("Please enter an interger greater than zero.");
      }while (isNaN(numChose) || numChose % 1 !== 0 || numChose &lt; 1 );
  
      function genTable(numChose)
      {
          var table = document.createElement("TABLE");
          var tableBody = document.createElement("TBODY");
          table.appendChild(tableBody);
          var myTableDiv = document.getElementById("mytable");
  
  
          for (var r = 0; r &lt;= numChose; r++)
              {
                  var tr = document.createElement("TR");
                  tableBody.appendChild(tr);
                  var td = document.createElement("TD");
                  tr.appendChild(td);
                  td.appendChild(document.createTextNode("Row " + r));
              }
       myTableDiv.appendChild(table);
      }
  
  
  
  &lt;/script&gt;
  
  
  
  &lt;/head&gt;
  
  &lt;body&gt; 
  
  &lt;div id="mytable"&gt;   
  &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>