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

my solution to the extra work he mentioned:

here is my code:

//Make Records searchable //Open Dialog box and request name of students //If theres a match print out the student data // If not not display a not found alert and ask again.

var message = ""; var results = 0;

while (true) { var search = prompt("Type Name Of Student:") search = search.toLowerCase();

if (search === null || search === "quit") { break; }

findName(search); if ( results > 0 ) { if (results < 2){ alert("We found " + results + " result!"); } else { alert("We found " + results + " results!"); } print(message); break; } else { alert("We found no results, Try again!"); }


function findName(input) { for (var i=0 ; i < students.length ; i++) { if (students[i].name.toLowerCase() === input) { for (var key in students[i]) { message += "<li>" + key + ": " + students[i][key] + "</li>"; } results++; } } }

function print(message) { document.getElementById("output").innerHTML = message; //the "output" is is the container where i want my files printed