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 trialChris Blues Explosion
4,276 PointsI think this works (after a few hours of screaming at the screen :) ). Is that ok? Anything that could be improved?
// Defining variables var message = ''; var student; var search; var studentGroup = [];
// To insert message directly into HTML function print (message) { var outputDiv = document.getElementById('list'); outputDiv.innerHTML = message; }
// To list the students properties/value pairs function getStudentReport(student) { var report = '<h2>Student : ' + student.name + '</h2>'; report += '<p> Track : ' + student.track + '</p>'; report += '<p>Achievements : ' + student.achievements + '</p>'; report += '<p>Points : ' + student.points + '</p>'; return report; }
// To search through student records while (true) { search = prompt("Type a student name, or type 'quit' to exit"); if (search === null || search.toUpperCase() === 'QUIT') { break; } for (var i = 0; i < students.length; i += 1) { student = students[i]; studentGroup.push(student.name); if ( student.name === search.toUpperCase() ) { message += getStudentReport(student); }// When there's no match } if ( studentGroup.indexOf(search.toUpperCase() ) <= -1 ) { alert(search + " is not a student."); } print(message); }