JavaScript JavaScript and the DOM 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?

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';
<!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; 2019</p> 
        <script src="app.js"></script>

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
Eric McKibbin
11,454 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 :)



Eric McKibbin
Eric McKibbin
11,454 Points

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