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 JavaScript Loops, Arrays and Objects Tracking Data Using Objects The Student Record Search Challenge Solution

Does anyone know a workaround for the while loop browser print issue?

I'm curious to know if anyone figured out a workaround for the print problem that prevents us from replicating the original video demonstration. I did a little bit of research and learned that the browser event loop is single-threaded, which I gather is the main reason for the print function not working as intended while in the loop.

I'd love to hear a more through explanation about what is happening under the hood to create this problem and any workaround ideas, if it's possible.

2 Answers

Steven Parker
Steven Parker
231,007 Points

This is a result of software changes in the browser itself.

When the video was made, browsers handled things differently internally. Since then, modern browsers have changed and the page rendering does not occur until the script completes.

But this demonstration uses a very simple and inelegant method of user interaction. There are other ways to do it (which work the same now as they always did) that involve creating interactive elements on the page and using them to get input from and display results to the user.

If you continue with the JavaScript course series, you'll learn these methods soon and you'll never again miss the "old days" when browsers did simultaneous rendering.

Thank you for your answer, Steven! I look forward to learning about the interactive elements and methods you mentioned.

Dennis Siller
PLUS
Dennis Siller
Courses Plus Student 1,681 Points

Thank you for the insight, Steven. Seems like Treehouse should put a disclaimer in the course about this issue, at least until they update their videos.

Steven Parker
Steven Parker
231,007 Points

I believe this is mentioned in the "Teacher's Notes", in at least of one the courses.