title: Trying to create a simple function that changes the background color of my page
body: <p>As the title says I am trying to create a function that achieves it.</p>
  
  <p>Here is my JavaScript:  </p>
  
  <pre><code>var clickCount = 0;
  var colors = ["red", "blue", "green"];
  
  function changBgColor(color) {
      var bodyTag = document.getElementsByTagName("body");
      bodyTag[0].style.backgroundColor = color;
  }
  
  function changeBg() {
      changeBgColor(colors[clickCount]);
      clickCount++;
  
      clickCount = clickCount % bgColors.length;
  }
  </code></pre>
  
  <p>When the function <code>changeBg()</code> is called from my html it does nothing and I'm scratching my head trying to understand why.</p>