title: Implementing getElementsByClassName using Recursion
body: <p>I created a function within getElementsByClassName that tests the current node to check if it matches the className, then recursively tests the childNodes of the current node.</p>
  
  <p>To me, this logically make sense, but I'm not sure why the results don't produce identical results as getElementsByClassName. I tried implementing a for loop that checks every node in the current level, but that doesn't seem to be working either. What do I need to adjust in the first if statement to get this code working?</p>
  
  <pre><code>function getElementsByClassName (className) {
    var nodeList = [];
    function test(node) {
        if (node.classList === className) {
          nodeList.push(node.classList[count]);
        }
      for (var index = 0; index &lt; node.childNodes.length; index++) {
        test(node.childNodes[index]);
      }
    }
    test(document.body)
    return nodeList;
  };
  </code></pre>