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 trialAn Phuc Huynh
Full Stack JavaScript Techdegree Student 7,501 Pointsworkspace has problem with document.write();
when I used document.write() to launch Workspace; it doesn't display on review but it works when I change to alert().
document.write() works when I used brackets instead of workspace.
3 Answers
Steven Parker
231,268 PointsThe workspace creates a webserver that your browser connects to, so it's your browser that provides the preview. And unlike your editor, browswers don't render the page until the script is completely finished. But "alert" is immediate.
As you progress, you'll soon learn other methods for creating fully interactive scripts in the browser.
kaash ka
750 Pointsuse document.write () instead of Document.write();
Steven Parker
231,268 PointsIsn't that what he said he was using?
Walter Young
Courses Plus Student 3,523 PointsI was having a similar problem - I realized document.write doesn't work for me if I try to preview the .js file directly. Instead, I need to preview the index.html file that is linked to the js file. That seemed to fix things for me. I would imagine this has something to do with how browsers handle document.write()?
Steven Parker
231,268 PointsIf you preview the .js file directly, you'd only see the code itself. You need to look at the page to see the results of the code running.