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

Alan Rudziński
Alan Rudziński
4,244 Points

Not passing tests

Why i am not passing tests even though all paragraphs are blue as mentioned in the task?

app.js
var section = document.querySelector('section');
var paragraphs = section.children;
var footer = document.querySelector('footer');
var footerPara = footer.children;

for (let i = 0; i < paragraphs.length; i++) {
  paragraphs[i].style.backgroundColor = 'blue';
}

footerPara[0].style.backgroundColor = 'blue';
index.html
<!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>&copy; 2019</p> 
        </footer>
        <script src="app.js"></script>
    </body>
</html>

in task 2 ur being asked only yo change the color of the p tags not the background.

so change the code to :

 paragraphs[i].style.color = 'blue';

1 Answer

Eric M
Eric M
11,545 Points

Hi Alan,

The bummer message for the code you posted should read: Bummer: Make sure to change the text color of all paragraphs to blue. Note that it says text color and your code changes the background color.

The instruction to "change the color of each child paragraph to blue" could be clearer and say "change the text color of each child paragraph to blue".

I'm sure with this info you'll be able to get it :)

Cheers,

Eric

Eric M
Eric M
11,545 Points

Ah, bot.net, I didn't see your comment before answering, just that the post had no answers, you're absolutely right of course!