Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
travis halarewich9,165 Points
i do not understand what this question is asking, i do not see how my answer is wrong
How would you select the
body element using document.getElementsByTagName, and store it in the variable body?
(Hint: Don't forget that this method returns a zero-based collection, not a single element.)
const body = _______ [_];
above is what you are given for the fill in the blank and below is my answer
const body = document.getElementsByTagName["body"];
all i get back is that what i have said is wrong and no feed back as to what is right
document.getElementsByTagName('body') gets a collection of body Elements (there is of course only one body element). Therefore it is the first element in the collection.
The solution is: document.getElementsByTagName('body');
See the hint provided: Don't forget that this method returns a zero-based collection, not a single element. You will have to specify the first (even though it is the only) element in the collection by using its index .