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 trialMax Peterson
1,723 Pointsi 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'
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script src="app.js"></script>
</body>
</html>
Justin Hicks
14,290 PointsHello 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
231,269 PointsAny 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>";
document.write(title);
Justin Hicks
14,290 PointsThe 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.
Troy Anderson
647 PointsTroy Anderson
647 Pointsif i'm not mistaken the document.write go inside the html tag <body> doucment.write() </body>