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! While you're at it, check out some resources Treehouse students have shared here.
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 trialSarah Breidenbach
4,490 PointsHow do I place the new element p as the last child element stored in the div constant (quiz question on Appending Nodes)
const div = document.querySelector('div#feedback');
const p = document.createElement('p');
____.appendChild( ____ );
2 Answers
Jose A Reynaldo Vazquez
21,313 Pointsdiv.appendChild(p);
Without quotes is Variable.
Robert Anthony
19,952 PointsappendChild is a function which acts on a parent and appends a new child. so Parent.appendChild(NewChild). In this case, what is the Parent (ie where do you want to put what you are appending?) and what is the name of the NewChild (what do you want to append?)
Sarah Breidenbach
4,490 PointsI understood the basic concept but I used quotes where I shouldn't have
div.appendChild('p');
I think I was thrown because the variable was named p the same as the element.
I was also confused about having it be the last child element, but I guess it's the last one automatically.