Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Interactive Web Pages with JavaScript Traversing and Manipulating the DOM with JavaScript Traversing Elements

Task 1 no longer passing

Whenever i try to complete task 2, the message says that task 1 no longer passes. I didnt change anything in code for task 1. Help!

//Select the navigation
var navigation = document.getElementById("navigation");

//Select all listItems from the navigation
var listItems = navigation.children;

//When a navigation link is pressed
var linkListener = function() {
  console.log("Listener is clicked!");

var bindEventsToLinks = function(listItem) {
  //Select the anchor
  var anchor = listItems.querySelector("a");
  //Bind the linkListener to the anchor element (a) 
  anchor.onclick = linkListener;

for(var i = 0; i < listItems.length ; i++) {
<!DOCTYPE html>

<ul id="navigation">
    <a href="#home">Home</a>
    <a href="#about">About</a>
    <a href="#contact">Contact</a>

<p>A few of my favourite things:</p>
    Rain drops on roses
    Whiskers on kittens
    Brown paper packages wrapped up with string

<script src="app.js"></script>

2 Answers

Steven Parker
Steven Parker
216,012 Points

:point_right: It looks like you just have a typo.

You spelled listItem as a plural (you have "listItems" with an extra "s").

This caused an error when the script attempted to access the method querySelector on an undefined object. Since the error invalidates the entire program, and the checker re-tests task 1 first, it mistakenly assumed something had gone wrong with task 1.

thanks! It was another thing. But it was so stupid of me. Next day i figured it out in 1 minute. Thx for reply!