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 trialZaid Shakil
3,198 PointsMy code doesn't show the data until i quit.
var message = '';
var student;
var ask;
function print(message){
var outputDiv = document.getElementById('output');
outputDiv.innerHTML = message;
}
function getStudent(student){
var report = '<h2>Student: ' + student.name + '</h2>';
report += '<h2>Student: ' + student.track + '</h2>';
report += '<h2>Student: ' + student.achievements + '</h2>';
report += '<h2>Student: ' + student.points + '</h2>';
return report;
}
while (true){
ask = prompt("Search student name (Type quit to exit)");
if (ask.toLowerCase() === "quit"){
break;
}
for (var i = 0; i < students.length; i++){
student = students[i];
if (ask === student.name){
message = getStudent(student);
print(message);
}
}
}
```
4 Answers
Zaid Shakil
3,198 PointsIs treehouse forum dead ? No body helps
Kyle Johnson
33,528 PointsYour code looks the same as mine. Have you tried opening the JavaScript Console to see if there is any errors?
Zaid Shakil
3,198 PointsYes mate ! no errors at all.
minzawmra
Courses Plus Student 15,682 PointsI was having the exact same problem. To verify that print
wasn't working, I put an alert with the formatted message. If I do document.write
, it doesn't work either. Then I switched my browser from Safari to Chrome and everything works!
It seems that Safari waits JavaScript executions to complete before rendering the page.
Edwin Alvarez
4,903 PointsI had the same problem with safari, but when I switched to chrome it worked fine.