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 
   
    Mihai Badic
4,246 PointsMy solution (works with multiple identical names and provides feedback on no results)
My solution below.
Notes: handles multiple students with the same first name / provides feedback when no entries found / the student info array " students" is in a diff file, like in the vid / went with a more UX friendly approach of just pressing cancel as opposed to also typing "quit") / message shown is only either the results or the no results message, info doesn't stack up
var userInput;
var recordsToReturn = '';
function print(message) {
    var outputDiv = document.getElementById('output');
    outputDiv.innerHTML = message;
}
while ( true ) {
    recordsToReturn = '';
    userInput = prompt('Search for student first name. Press cancel to stop');
    if ( userInput === null ) {
        break;
    }
    for ( i=0; i < students.length; i++ ) {
        if ( students[i].name.toUpperCase() === userInput.toUpperCase() ) {
            recordsToReturn += 
                '<p><strong>Student name: ' + students[i].name +
                '</strong></p> <p>Track: ' + students[i].track +
                '</p> <p>Achievements: ' + students[i].achievements +
                '</p> <p>Points: ' + students[i].points + '</p></br>'
            ;
        }
    }
    if ( recordsToReturn === '' ) {
        recordsToReturn = 'No student "' + userInput + '" was found.';
    }
    print(recordsToReturn);
}
1 Answer
 
    Mihai Badic
4,246 PointsIt was to a challenge in a video, it's a bit confusing seeing this post or posts like this in the forum and not just under the exact video(s) referenced, think that's a general issue on Treehouse.
Craig Garner
25,732 PointsCraig Garner
25,732 PointsWhat is the problem?