Selection Review Quiz Questions:
On the quiz there is a question which asks how to select the body tag using document.getElementsByTagName and to assign it to the variable body.
They give you the start const body then an input field to put your answer. I have tried so many ways but always says wrong answer!
I put in: document.getElementsByTagName('body');
What am i doing wrong?
Steven Parker203,212 Points
You forgot to apply the index for the "zero" element.
The function returns a collection, so if you want just a single element you have to apply an index. Since there's only one "body" element, the index will be 0.
Elizabeth Chai9,692 Points
Just the question I was looking for. Was so confused and tried the quiz a few times...