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

Karl Jones
Karl Jones
8,761 Points

It's not pretty but it works... or... An interesting solution to the extra challenges

https://w.trhou.se/7l269347qg

I found I had accidentally created a solution for the repeat records problem :) by simply using the += to build the output message each time it checked a student with the same name in the for loop, it would just list it below. Like wise if you search Dave ENTER, Jordan ENTER, quit. It will show both Dave and then Jordan below.

I also solved the no student found problem with a somewhat inelegant solution but hey it works.. If the search name does not match the student, it adds 1 to a notFound variable. At the end of the loop, if this variable matches the length of the student array, ie all students were marked as not found, then it show an error. This gets around the iteration of the for loop overwriting any found students.

Feedback always appreciated.