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 trial

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
231,269 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
231,269 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
231,269 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.