var getElementsByClassName = function(className) { var listArray = []; // START INNER FUNCTION var innerFn = function(node) { if (node.nodeType === 1) { if (node.classList.value.includes(className)) { listArray.push(node); } } node.childNodes.forEach( function(element) { return innerFn(element); }); }; // END INNER FUNCTION innerFn(document.body); return listArray; };