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 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
231,122 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.