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 trialNikola Jankovic
10,793 PointsThis is solution for two additional problems.
var message= '';
var student;
var question;
var answer= false;
function print(message){
document.write(message);
}
function getReport (student) {
var report= '<h2> Student name is '+student.name+' </h2>';
report+= '<p> Student track is '+student.track+' </p>';
report+='<p> Student achivements are ' +student.achievements+ ' </p>';
report+= '<p> Student points are '+student.points+' </p>';
return report;
}
while (true) {
question= prompt('Who are you looking for?');
student=students[i]
if (question=== null || question.toLowerCase()=== 'quit'){
break;
}
for (var i=0; i<students.length; i+=1) {
student=students[i];
if (student.name.toLowerCase()=== question.toLowerCase() ) {
answer= true;
print(getReport(student));
}
}
if (! answer){
alert('This name is not in the records!');
}
}
Ivaylo Aleksiev
1,724 PointsYour code doesn't take into account the problem with 2 students with the same first name. In order to print them all you should append your report string to the global variable message inside getReport( student )
Omar Hamza
Courses Plus Student 1,985 PointsOmar Hamza
Courses Plus Student 1,985 PointsThank you :)