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 trialVadim Selivonchik
3,997 Pointscomment my solution please
let html = '';
let student;
let request;
let studentNames = [];
let names = [];
function print(message) {
let outputDiv = document.getElementById('output');
outputDiv.innerHTML = message;
}
for (let i = 0; i < students.length; i++) {
student = students[i];
studentNames.push(student.name);
}
function getReport (student) {
report = '<h4>Student: ' + student.name + '</h4>';
report += '<p>Track: ' + student.track + '</p>';
report += '<p>achievements: ' + student.achievements + '</p>';
report += '<p>points: ' + student.points + '</p>';
return report;
}
for (let i = 0; i < students.length; i++) {
student = students[i];
names.push(student.name);
}
while (true) {
request = prompt("Type name or quit");
if (request == null ||
request.toLowerCase() == 'quit') {
break;
} else if ( names.indexOf(request) == -1 ) {
alert('there is no that student');
}
for (let i = 0; i < students.length; i++) {
student = students[i];
if (request == student.name) {
html += getReport(student) ;
print(html);
}
}
}
2 Answers
Steven Parker
231,275 PointsAt first glance, it looks like you have the classic code implementation for this exercise.
Good job.
Vadim Selivonchik
3,997 PointsThanks for answer
Vadim Selivonchik
3,997 PointsVadim Selivonchik
3,997 PointsCan I improve something?
Steven Parker
231,275 PointsSteven Parker
231,275 PointsAnything I can think of you might improve would involve a technique that probably hasn't been covered yet (like template literals).