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

Peter Retvari
seal-mask
.a{fill-rule:evenodd;}techdegree
Peter Retvari
Full Stack JavaScript Techdegree Student 8,392 Points

Solved the "duplicate values" and the "we don't have this student" challenge

Hey folks,

Dave presented in the last 30 sec of this video about a problem with this code:

  • What if more than one student has the same name?
  • The program won't pop up an alert window if the user type a student that doesn't exist in the database, however it would be nice.

Finally I found a solution for both problem. I wonder if you could check is it nice/ok/stupid, etc., or if you have a better, shorter solution just share with me/us.

Here you can find my little program:

https://w.trhou.se/re4c9dxcxp

Many thanks,

Peace

2 Answers

Steven Parker
Steven Parker
229,982 Points

It looks like you've accomplished the objectives, good job. :+1:

I can think of two suggestions:

  • store names with normal casing, but convert them for comparing to make the search case-insensitive
  • make the search work directly with the object array so a separate names array is not needed
Peter Retvari
seal-mask
.a{fill-rule:evenodd;}techdegree
Peter Retvari
Full Stack JavaScript Techdegree Student 8,392 Points

Thanks, Steven for your quick help (as usual ??? ). Yes, finally I finished it :) However, I already started the first project in Techdegree so I would like to focus on that part, but I will get back to this code and correct it ASAP, because I would like to solve the case-sensitive thing and the search directly with object challenge.