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 Solution

Need help figuring out why no student data prints to page.

https://w.trhou.se/zw3t4kotc9

the prompt search works, and when I enter quit it exits the alert, but nothing happens when I search for students

2 Answers

Steven Parker
Steven Parker
215,972 Points

It worked fine for me. :+1:

I did notice that the search is case-sensitive, so if you enter "dave" it will not find anything.

But it finds "Dave" and displays the information.

That worked I didn't pay close enough attention to what he was doing in the video. Say I wanted to be able to enter the student's name in any case, I tried

search = prompt.toLowerCase('Enter a students name [Jody], or type "quit" to exit');

But this didn't work, any suggestions?

Steven Parker
Steven Parker
215,972 Points

You need to apply the conversion function after the prompt function, like this:

search = prompt('Enter a students name [Jody], or type "quit" to exit').toLowerCase();

And that's just half of process, you need to convert the name to lower case also so it will match:

  if (student.name.toLowerCase() === search) {

I made those changes and it works no if I type it in lowercase like this 'jody', but now it doesn't work when I enter it like I had to before 'Jody', very strange because I thought the whole point to .toLowerCase() was to be able to type in any case and have the information still math up.

Nevermind I went back and check my code, that worked I just hadn't made all the changes.