1
2
3
4
5
6
7
8
9
10
To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to CodePen.
0,1,2,3,4,5,6,7,8,9
0
0
0
0
The alternative to childNodes[0] is _________. | firstChild | firstChild | |
The alternative to children[0] is _________. | firstElementChild | firstElementChild | |
A div has been assigned to a variable, parent. Assign its last non-whitespace child to the variable lastParagraph. The variable hasn't been declared beforehand. | let lastParagraph = parent.lastElementChild; | letlastParagraph=parent\.lastElementChild; | |
A div has been assigned to a variable, parent. An <h2> heading is the first child of the div that isn't whitespace. Display the text content of the heading in the console. | console.log(parent.firstElementChild.textContent); | console\.log\(parent\.firstElementChild\.textContent\); | |
In the console, display the node name of the last element node of a div that's been assigned to the variable mainDiv. Do it with a single statement. | console.log(mainDiv.lastElementChild.nodeName); | console\.log\(mainDiv\.lastElementChild\.nodeName\); | |
An element has been assigned to the variable el. Code this: If the first child of el is text, display a message in the console. Make up the message. | if (el.firstChild.nodeName === "#text") { console.log("Text node!"); } |
if\(el\.firstChild\.nodeName===•#text•\){[\r\n]console\.log\(•.*•\); | |
Using what you learned in this chapter, assign the next element sibling of the first child of a parent to a variable. Make up the name of the variable that represents the parent and the variable that represents the sibling. | let sib = parentEl.firstElementChild.nextElementSibling; | let[a-z_$][a-zA-Z0-9_$]*=[a-z_$][a-zA-Z0-9_$]*\.firstElementChild\.nextElementSibling; | |
An ordered list has been assigned to the variable parentElement. In the console display the text content of the last element child of parentElement. | console.log(parentElement.lastElementChild.textContent); | console\.log\(parentElement\.lastElementChild\.textContent\); | |
|
|||
|