JavaScript JavaScript and the DOM Getting a Handle on the DOM Selection Review

henry duquesnay
henry duquesnay
6,976 Points

Do what now? What did i do wrong?

it looked like I answered correctly. not sure what is incorrect. All the previously helped people for this question seem to indicate to me that i guessed correctly. Where'd I mess up?

Eric McKibbin
Eric McKibbin
Treehouse Moderator 11,450 Points

Hi Henry,

Which question are you having trouble with and what answer are you trying?

Cheers,

Eric

henry duquesnay
henry duquesnay
6,976 Points

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 = getElementsByTagName('body')[0]; (DID NOT WORK?)

1 Answer

Sean T. Unwin
MOD
Sean T. Unwin
Treehouse Moderator 28,388 Points

Hi Henry,

You're very close! The only part that is missing is to preface the function call with document.

The result should be:

const body = document.getElementsByTagName('body')[0];