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 Basics (Retired) Introducing JavaScript Your First JavaScript Program

Monika Agarwal
Monika Agarwal
55 Points

the alert does not work as per the video.in my case both the alerts popped simultaneously one after the other

as per the video the sequence of the statements should be first alert then page and then alert .

Luis Onate
Luis Onate
13,222 Points

Could you paste your code so we can see it? If you paste your code between sets of 3 backticks (```) we'll be able to see if more clearly.

4 Answers

Steven Parker
Steven Parker
231,236 Points

It could be the browser.

Not long ago, it was common for browsers to display page info while the JavaScript was running, but now it's more common for the browser to wait until the JavaScript program finished before displaying the rendered page.

So it would make sense that with modern browsers, both alerts would be displayed as the program runs, but anything written to the page would not be seen until the program ended. The browser used in the video probably had a different behavior.

The latest version of Safari appears to do precisely this. Both alerts appear before the document.write part is written to the page.

same with me i'm using chrome on w10

Steven Parker
Steven Parker
231,236 Points

As I said, that's the way browsers work now.

got that ;)