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 trialj s
221 PointsJS is not executing in order what sir says why?
Dave McFarland sir why mine is not same as your output
alert("Hello world"); document.write("<h1>Hello world</h1>"); alert();
as sir says that JS engine execute it in one by one order but in my chrome browser first alert comes that says "Hello world" and then i click on OK button H1 tag not execute another alert comes and after second alert's executes and i click on its OK button H1 then appears why so in sirs browser alert comes h1 comes and alert comes why my is not same
Steven Parker
231,275 PointsBut Jarratt, running the alert both before and after the write was the purpose of the demonstration.
7 Answers
Steven Parker
231,275 PointsModern browsers work a bit differently than the one in the video.
Most browsers now display the rendered page only after the initial JavaScript has completely finished.
The browser in the video displayed the page while the JavaScript was still running.
This should probably be mentioned in the "teacher's notes". You might want to report this as a bug using the Support page - it may even get you a "special Exterminator badge".
Dave McFarland
Treehouse TeacherSorry about that! Thanks Steven Parker for steering j s in the correct direction. I'm in the middle of updating several videos in this course that suffer from this same problem, so a fix should be in sometime (relatively) soon -- holidays are here, so probably not until beginning of January.
Daniyell Augusta
Courses Plus Student 495 PointsI like how teachers can easily comment here. Very nice.
Gabor Galantai
Courses Plus Student 17,247 PointsDave McFarland how is the updating of the videos going? I still see this problem.
ywang04
6,762 PointsAlso the same issue.
Jon Speake
3,466 PointsStill same issue.
carinaortiz
2,358 PointsSame here
Ryan Patric
205 PointsDave McFarland Still seeing it here as well.
Ian Ha
Front End Web Development Techdegree Student 5,102 PointsStill the same probelm!
Nick Post
Courses Plus Student 3,155 PointsSame issue...... came here and it said this bug was to be worked out in January? Was that of 2017?
Jarratt Isted
2,437 PointsJarratt Isted
2,437 PointsPretty sure it's because you're executing the
alert();
function more than once. It might be helpful to write the code on separate lines for clarity, too.If you want your code to run an alert and then write to the document, try this:
You don't need to use the
alert();
function twice.