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 trial

JavaScript JavaScript and the DOM (Retiring) Traversing the DOM Child Traversal

Igor Pavlenko
Igor Pavlenko
12,925 Points

cant figure out what is wrong?

please check where is the mistake ?

const section = document.querySelector('section');
let paragraphs = section.children;

for (var i = 0; i < paragraphs.lenght; i ++) {
      paragraphs[i].style.color = 'blue';
<!DOCTYPE html>
        <title>Child Traversal</title>
            <p>This is the first paragraph</p>
            <p>This is a slightly longer, second paragraph</p>
            <p>Shorter, last paragraph</p>
            <p>&copy; 2016</p> 
        <script src="app.js"></script>

2 Answers

nico dev
nico dev
20,364 Points

Hi Igor Pavlenko ,

Only a little misspelling.

Where you said:

i < paragraphs.lenght;

You probably meant:

i < paragraphs.length;

But the code and the logic behind seem perfect.

Igor Pavlenko
Igor Pavlenko
12,925 Points

thnx for quick response!!

i always do this spelling stuff; sometimes i break my head for 15 minutes to see 1 letter missing somewhere lol

nico dev
nico dev
20,364 Points

Ha ha, believe me it happens to all of us! :)