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

On the The Student Record Search Challenge Solution , it only displays data after quitting

Here is my code : var message = ''; var student; var search;

function getStudentReport(student) { var report='<h2>Student: '+ student.name + '</h2>'; report+='<p> Track: '+ student.track+'</p>'; report+='<p> Points: '+ student.points+'</p>'; report+='<p> Achievements: '+ student.achievements+'</p>'; return report; }

function print(message) {

var div =document.getElementById('output'); div.innerHTML=message; }

while (true) { search = prompt("Search for a student in our school. Type 'list' to show all of the produce and 'quit' to exit");

if (search ===null || search.toLowerCase() === 'quit') { break; }

for (var i=0; i < students.length; i+=1) {
  student=students[i];
  if(student.name===search) {
    message=getStudentReport(student);
    print(message);
        }
  }
}

2 Answers

Steven Parker
Steven Parker
243,266 Points

Things have changed since the videos were made, and now it's typical for browsers to delay rendering the page until the script has completely finished.

I believe this is explained in the "Teacher's Notes" section on one of the pages of that course.

Thanks Steven. I couldn't help but notice you have 150,00+ points, not often i come across someone with that much experience. Thanks :)

Steven Parker
Steven Parker
243,266 Points

Admittedly, about half of that comes from forum participation, so I do answer a lot of questions. There are many courses available that I have not taken yet!

Happy coding!

Thanks!