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 JavaScript Loops, Arrays and Objects Tracking Data Using Objects The Student Record Search Challenge

What's wrong with my code?

https://w.trhou.se/r9cyq90gps

Nothing prints on the page or the web console. What am I missing?

2 Answers

Steven Parker
Steven Parker
210,487 Points

There's a few issues:

  • when calling "toLowerCase", the name must be followed by parentheses "()"
  • a second loop isn't needed, but you can assign "data" to the indexed student
  • "students" is the entire array, the properties should be accessed on "data" instead
  • the individual property names should be shown instead of "Name" for each one
  • the "print" call needs to be inside the conditional block
      if (search === students[i].name.toLowerCase()) {
        var data = students[i];
        html += "<h2>Name: " + data.name + "</h2>";
        html += "<p>Track: " + data.track + "</p>";
        html += "<p>Achievments: " + data.achievments + "</p>";
        html += "<p>Points: " + data.points + "</p>";
        print(html);
      }

Steven. You, sir, are one awesome brother. Thank you.