JavaScript JavaScript and the DOM Traversing the DOM Child Traversal

Alan Rudziński
Alan Rudziński
4,241 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>
status 401
status 401
14,144 Points

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 McKibbin
MOD
Eric McKibbin
Treehouse Moderator 11,433 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 McKibbin
Eric McKibbin
Treehouse Moderator 11,433 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!