title: Print from JavaScript function to HTML without document.write()
body: <p>I searched everywhere on here on an alternative on printing to HTML from a JavaScript function to HTML without using document.write() but document.getElementById() doesn't seem to work and I'm really not sure how to go about doing this.</p>
  
  <p>I have this so far</p>
  
  <p><strong>JavaScript</strong></p>
  
  <pre><code>function trials() {
  
      while (num_trials &gt; 0) {
  
          for (var i = 0; i &lt; random.length; i++) {
              document.write(random[i]);
          } 
      }
  }
  </code></pre>
  
  <p>Where "random" is an array of letters</p>
  
  <p><strong>HTML</strong> </p>
  
  <pre><code>    &lt;div id ="container"&gt;
      &lt;center&gt;
          &lt;i&gt;**TRIALS HERE**&lt;/i&gt;&lt;br&gt;&lt;br&gt;
          &lt;font size="8"&gt;
          &lt;script&gt;trials();&lt;/script&gt;&lt;br&gt;&lt;br&gt;
          &lt;/font&gt; 
      &lt;/center&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I'm also looking for a way to hide each letter after each iteration of the for-loop so that it doesn't just print as a long string of letters. </p>