Simply JS DOM Tree navigation

I’ve come across a problem with the getElementsByClassName function I build starting on page 74 of Simply JavaScript.

Here is my js

Core.getElementsByClass = function (theClass) {
var elementArray = ;

if (typeof document.all != "undefined") {
	elementArray = document.all;
} else {
 	elementArray = document.getElementsByTagName("*");
}
var matchedArray = [];
var pattern = new RegExp("(^| )" + theClass + "( |$)");
 
for (var i = 0; i < elementArray.length; i++) {
	if (pattern.test(elementArray[i].className)) {
		matchedArray[matchedArray.length] = elementArray[i];
 	}
}
return matchedArray;
//console.log(matchedArray);

};
var elementArray = Core.getElementsByClass(“datatable”);
console.log(elementArray);

and here is my html minus the body, head, html tags and loaded core.js library

<ul class=“datatable”>
<li>Stuff</li>
<li>Stuff</li>
<li>Stuff</li>
<li>Stuff</li>
</ul>
<ul class=“datatable”>
<li>Stuff</li>
<li>Stuff</li>
<li>Stuff</li>
<li>Stuff</li>
</ul>
<ul class=“datatable”>
<li>Stuff</li>
<li>Stuff</li>
<li>Stuff</li>
<li>Stuff</li>
</ul>

when I console.log the elementArray i get an array, but there are no child objects. Shouldn’t I be getting an actual count of the array list instead?

Also…
the baldwins example for finding a child element via the unorderlist

var baldwins = document.getElementById(“baldwins”);

logging baldwins in firebug returns null???

same goes for finding a parent

Please help :sick: