title: In Javascript, how do I print out a single element in an array every 5 seconds?
body: <p>I have a pre made class [<strong>Msg</strong>] with methods [<strong>.show()</strong> and <strong>.retrieve()</strong>]. The method '.show()' displays a message to the browser as the last list item in an unordered list. The method '.retrieve()' gets a finite amount of messages from a server. It takes a callback method as its only parameter. It will pass an array of strings. Each string in the array contains one message. I have the following code: </p>
  
  <p><strong>JS:</strong></p>
  
  <pre><code> Msg.retrieve(function(array) {
        for (var i = 0; i &lt; array.length; i++) {
             Msg.show(array[i]); 
        }
   });
  
   // The code outputs all the messages to the screen at once as a bunch of list items. 
  </code></pre>
  
  <p><em>How do I output one message every five seconds?</em> I am unsure on how to use the setInterval() method Javascript has.</p>
  
  <p>Any help is greatly appreciated. Thanks!</p>