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) Storing and Tracking Information with Variables The Variable Challenge Solution

Vitaly Khe
Vitaly Khe
7,160 Points

null null null .. etc.. on following code:

var sentence = ''; while(sentence != 'The end.'){ sentence = prompt("Write next sentence. Type: 'The end.' to finish story."); document.write('<p>' + sentence + '</p>'); }

Is there a workspace bug?

5 Answers

Steven Parker
Steven Parker
210,425 Points

By itself, this code seems to work as expected.

To facilitate a complete analysis, make a snapshot of your workspace and post the link to it here.

Steven Parker
Steven Parker
210,425 Points

The code still seems to work in the complete environment. I only see "null" displayed if I press the "cancel" button instead of entering a paragraph.

Is that your issue? If so, you might want to add this as the 2nd line of the loop:

  if (sentence == null) break;

Otherwise, please describe what is happening more explicitly along what what you expect it to do differently.

Vitaly Khe
Vitaly Khe
7,160 Points

Issue is not that you mentioned above and reproducible in Opera only. Chrome works as expected.

Console.log: 583port-80-6lb5bqawr4.treehouse-app.com/:1 A window.prompt() dialog generated by this page was suppressed because this page is not the active tab of the front window. Please make sure your dialogs are triggered by user interactions to avoid this situation. https://www.chromestatus.com/feature/5637107137642496

ScreenCast: https://youtu.be/l_ABifYBUs0

Steven Parker
Steven Parker
210,425 Points

That error message is sure odd. Why would the page not be the active tab? Maybe it would help to add a "start" button to the page and use that to trigger the rest of the script (giving it that "user interaction").

I many not be help to help further on this one, I don't use Opera or have it installed.