Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
210,146 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.

Andrew Phythian
Andrew Phythian
19,747 Points

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
210,146 Points

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

got that ;)