Welcome to the Treehouse Community
Looking to learn something new?
Jake Kobs9,215 Points
Why won't firstChild work for the code challenge?
Here's the code that works:
let myList = document.getElementsByTagName("ul"); let firstListItem = myList.children;
Why wont the following code work? Doesn't it mean the same thing?
let myList = document.getElementsByTagName("ul"); let firstListItem = myList.firstChild;
Steven Parker215,940 Points
The "children" property returns only elements but the "firstChild" property returns the first node, which is not guaranteed to be an element.
What you probably want instead is "firstElementChild".