JavaScript JavaScript Loops, Arrays and Objects Tracking Data Using Objects The Student Record Search Challenge Solution

Will Albertsen
Will Albertsen
Full Stack JavaScript Techdegree Student 7,649 Points

Nothing prints to page until the while loop breaks

I noticed in the tutorial video that the contents of the message variable were printing to the page right after Dave clicked okay, which makes the program much more effective.

The problem is in my program the message content doesn't print until the while loop breaks so you don't see any information printed until either 'quit' is printed in the dialog box or the cancel button is pressed.

Below is a link to my code. The only code I changed was in the student_report.js file. Not sure if it is an issue with the code or something else.

https://w.trhou.se/08e5ibjion

2 Answers

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 47,441 Points

See the teacher's notes for the video

Important Update 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.

Antti Lylander
Antti Lylander
9,659 Points

Answering without reading your code. Browser behavior has changed and dom is not updated until the loop has finished. So, probably that explains your trouble. Some of the videos are outdated. Did you check teacher's notes?