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

JS executes in diff order than shown & the vid shows the doc.write<h1> text inside the input, but mine shows up below it

I'm using Chrome and have been following along for months without any issues until starting JS.

(1) alert("Hello from Alex");

(2) document.write("<h1>Welcome to my Website!</h1>");

(3) alert("Thanks for stopping by");

WHAT SHOULD BE: Video shows the first alert (1), then the text for document.write<h1> appears inside the input box (2), and finally the last alert appears (3).

WHAT IS: My 3 JS lines are occurring (1) (3) (2), with both alerts (1) & (3) executing before the document.write<h1> text (2). Also, my document.write<h1> text is showing up outside of and below the input box, but it is inside of the input for the video...

CAN SOMEONE PLEASE HELP ME UNDERSTAND WHAT I'M DOING WRONG OR WHAT I'M MISSING??

4 Answers

Steven Parker
Steven Parker
210,146 Points

I don't think you've done anything wrong, the video is probably a few years old and browser behavior has changed since then. New browsers don't reder anything to the page until the script has completed, so it's normal to see both alerts first.

Also, the appearance of the message would be affected by both the HTML and CSS parts of the code, which are not shown here. You can share a complete workspace by using the "snapshot" function (the camera icon) and then posting the link it gives you here.

Lesley Bulbeck
Lesley Bulbeck
1,583 Points

I experience exactly the same too. Thanks for the answer about browser behaviour. If things have moved on, should the video be updated, Treehouse?

Steven Parker
Steven Parker
210,146 Points

Other than a complete course re-do (they call it "refresh"), I don't think the videos get changed. But in at least one of the videos there's a mention of this in the "Teacher's Notes" section.

I'm experiencing the same thing as alex, I agree it's likely the browser.

Lesley Bulbeck
Lesley Bulbeck
1,583 Points

Thanks, Steven. So you'd recommend checking the Teacher's Notes section if we suspect that a video may be out of date?

Steven Parker
Steven Parker
210,146 Points

Not just then, the Teacher's Notes often contain useful information either directly about the video or related to the information presented. I'd say always take a quick look to see if anything is in there.