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 trialAndrew Meehan
998 PointsIn 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
1 Answer
Kelvin Parker
3,335 PointsHi! 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.
Andrew Meehan
998 PointsAndrew Meehan
998 PointsThanks Kelvin!