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 trialidriss Elouilani
Courses Plus Student 1,232 PointsI didn't use document write function ?
I didn't use document write function but it seem to me I used as function
var player = "Jasmine";
document.write = ("player");
<!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>
1 Answer
Jennifer Nordell
Treehouse TeacherHi there! You're close, but it's not quite right. Remember, we use an equals sign when we're making an assignment. But there is no assignment that needs to happen. To run a function, we simply use the name of the function and a set of parentheses. In the parentheses we place any arguments (data we're sending to the function). Also, you're making player
a string literal instead of using the variable player
. A variable is not surrounded by quotation marks.
The line you're looking for is:
document.write(player);
This calls the write function on the document and sends it the value stored in the player
variable. The result is that the name "Jasmine" will be written to the document.
Hope this helps!