title: insertBefore on two class names
body: <p>I am having trouble with my code. I am creating new divs then inserting them before every element with the class of <code>time</code> and <code>time2</code>. Unfortunately my code does not working I get insertBefore is undefined error. I suspect its my for loop but I need further help.</p>
  
  <pre><code>window.onload = function () {
      var badges, timeOne, timeTwo, parentDiv;
  
      timeOne = document.getElementsByClassName("time");
      timeTwo = document.getElementsByClassName("time2");
  
      for (index = 0; index &lt; timeOne.length; ++index) {
          badges = document.createElement("div");
          badges.id = "badges";
          parentDiv = timeOne.parentNode;
          parentDiv.insertBefore(badges, timeOne[index]);
      }
  
      for (index = 0; index &lt; timeTwo.length; ++index) {
          badges = document.createElement("div");
          badges.id = "badges";
          parentDiv = timeTwo.parentNode;
          parentDiv.insertBefore(badges, timeTwo[index]);
      }
  }
  </code></pre>