title: Javascript: Change HTML Text using an Array
body: <p>Hi at the moment i have some Javascript that makes my image loop through automatically multiple images stored in a array, but how can i do the same thing with text on a H2 text object?</p>
  
  <pre><code>&lt;SCRIPT LANGUAGE = "Javascript"&gt;
      var p1 = new Image();
      var p2 = new Image();
      var p3 = new Image();
      var p4 = new Image();
  
      p1.src="images/223.png";
      p2.src="images/335.png";
      p3.src="images/225.png";
      p4.src="images/226.png";
  
      var imgArray = new Array (p1, p2, p3, p4);
  
      var counter = 0;
      var loop = 1;
      setTimeout(scroll_forwards, 2000);
  
      var end = imgArray.length - 1;
  
      function scroll_forwards() {
          if (counter == end){
              counter = 0;    
          }
          else {
              counter++;
          }
          document.pic1.src = imgArray[counter].src;
          setTimeout(scroll_forwards, 2000);
      }
  &lt;/SCRIPT&gt;
  </code></pre>