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 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
229,645 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
229,645 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.