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 trialRobert Crocker
3,748 PointsMy code works in my environment
I am selecting all the elements with the children selector and it works in my environment, but I can pass this quiz.
const section = document.querySelector('section');
let paragraphs = section.children("p");
<!DOCTYPE html>
<html>
<head>
<title>Child Traversal</title>
</head>
<body>
<section>
<p>This is the first paragraph</p>
<p>This is a slightly longer, second paragraph</p>
<p>Shorter, last paragraph</p>
</section>
<footer>
<p>© 2016</p>
</footer>
<script src="app.js"></script>
</body>
</html>
2 Answers
Steven Parker
231,264 PointsI'm surprised to hear this works, the environment must be something rather unusual. I would expect you to get an error like "TypeError: section.children is not a function".
It is, however, an ordinary property and should work fine without the argument and parentheses.
Robert Crocker
3,748 Pointsconst section = document.querySelector('section'); console.log(section);
let paragraphs = section.children("p");
console.log(paragraphs);
console.logging paragraphs gives me an array of three ps
Steven Parker
231,264 PointsYou mean three more in addition to the ones shown inside section from the first log?
Most peculiar! I take it your "environment" is not any standard browser. Perhaps it's "auto correcting" the code and just ignoring the parentheses and argument completely?
But the challenge wants to see it done correctly.