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

Frank Lin
Frank Lin
4,888 Points

Challenge-solution: students have same name https://w.trhou.se/akc84lqq2i

SHARE the solution.

1 Answer

Good Job. Some comments:

1) If you are concerned about space or spaces you could use the trim() function

if(search.trim() ==='')

instead of

if(search===''||search===' ')

so any number of spaces will be handled

2) Check if search is null so Cancel is handled properly

3) Consider putting the code that generates the message from the array into a function so you don't repeat yourself

4) You could make it user friendly by making search case insensitive