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.
In the story, how do you make space between each word when the document.write function is executed?
When the story is printed out on the webpage, there are no spaces in between the words
Kelvin Parker3,335 Points
Hi! When using document.write() you have to include any spaces you wish to be seen in the string via the quotations as the variables won't display them. For example if you want to include an answer from a prompt in a sentence you'd do as follows:
var answer = prompt ("What is your answer?") document.write("Your answer was " + answer + ". Thanks for answering.")
This would display "Your answer was 'answer'. Thanks for answering."
Using your string to include the space and punctuation before and after the variable so on the page it make perfect grammatical sense.