title: Alternative to document.write()
body: <p>I was told that it's best to avoid using <code>document.write()</code> as much as possible. So how would you suggest I handle this code</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8" /&gt;
    &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
    &lt;title&gt;Debug&lt;/title&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
    &lt;script&gt;
      function writeTimesTable(num) {
        for(let i = 1; i &lt; 13; i++ ) {
          let writeString = i + " * " + num + " = ";
          writeString = writeString + (i * num);
          writeString = writeString + "&lt;br /&gt;";
          document.write(writeString);
        }
      }
  
    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;script&gt;
      for(let i = 1; i &lt;= 13; i++ ) {
        document.write("&lt;p&gt;")
        writeTimesTable(i) 
        document.write("&lt;/p&gt;")
  
      }
    &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I've tried a <code>innerHTML</code> but I keep getting an <code>undefined</code></p>
  
  <p>This is the code I used after </p>
  
  <pre><code>function writeTimesTable(num) {
    for(let i = 1; i &lt; 10; i++ ) {
      let writeString = i + " * " + num + " = ";
      writeString = writeString + (i * num);
      writeString = writeString + "&lt;br /&gt;";
      document.write(writeString);
    }
  }
  
  
  function newTable() {
    for(let i = 1; i &lt;= 10; i++ ) {
      let para = document.getElementById("paragraph");
      para.innerHTML = writeTimesTable(i)    
  
    }
  }
  </code></pre>