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

Braden Piper
Braden Piper
3,677 Points

How to get this to work with today's browser behavior... If you're having trouble, read the teacher's notes.

I'm seeing a lot of people getting frustrated, or wondering why their code "doesn't work" because they may have missed this teacher's note from Dave:

"Since this video was shot, the behavior of most browsers has changed, so you won't see the same thing as I demonstrate in the video. In the video, you'll see that my script is able to print out to the browser using document.write( ) while inside a loop.

Most browsers no longer do that: they wait until the loop finishes and then they print to the window. So, you'll see a blank page until you type quit in the prompt window — then you'll see all the output printed to the screen."

That's a nice explanation, but how would you actually get this to work given today's browser behavior? Is it just an irrelevant question? Or is this something that Javascript shouldn't be used for (trying to print to the document while running a function).

2 Answers

Steven Parker
Steven Parker
231,248 Points

If I wanted to display something during the initial program run, I would used alert instead of document.write.

But an even more elegant solution would be do user interaction using an onscreen form. This technique will be shown in later lessons.

Antti Lylander
Antti Lylander
9,686 Points

Oh god, this problem drove me nuts. Lesson learned, I'll read teacher's notes in the future. :)