title: Implementing getElementsByClassName recursively
body: <p>Trying to hand-code <code>getElementsByClassName</code> recursively.</p>
  
  <p>While the code works in my console, I'm not passing my test case in mocha. Assuming the test case was written correctly, what can I do to make my code better (read: more correct)?</p>
  
  <pre><code>var getElementsByClassName = function(className){
    var docBody = document.body;
    var classes = [];
    var walk = function (node, func) {
      func(node);
      node = node.firstChild;
      while (node) {
        walk(node, func);
        node = node.sibling;
      }
    }
    walk(docBody, function() { 
      if (docBody.classList.contains(className)) {
        classes.push(docBody)
      }
    });
    return classes;
  };
  </code></pre>