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 Create a variable with a string

i have been doing a lot of the videos per day and have forgotten how to put document.write into the html body.

the question asks me to use the document.write function to print the player variable onto the page and i have forgotten how to do that.

var player = 'Jasmine'
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
<script src="app.js"></script>

if i'm not mistaken the document.write go inside the html tag <body> doucment.write() </body>

Justin Hicks
Justin Hicks
14,290 Points

Hello Troy Document.write() is JavaScript that must be written in the app.js file

If it was to be written in the index.html file it would need to be contained with in a script tag which is not recommended.

JavaScript is written in a .js file to avoid cluttering html and JavaScript together among many other reasons.

2 Answers

Steven Parker
Steven Parker
217,569 Points

Any function call is just the name of the function followed by parentheses. Any argument(s) passed to the function go between the parentheses:

title = "<h1>This is a title</h1>";
Justin Hicks
Justin Hicks
14,290 Points

The body is the document object. So .write is a method on the document object. When you call document.write(); it’s 100% going to print out to the body because the body is part of the document object.

Just put in document.write(player); in the app.js file and you will see from that point it will click.