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

Matthew Hemphill
Matthew Hemphill
1,082 Points

string creation with document.write problem

I'm on the Javascript basics track and it's asking me to use the document.write () function to print the contents of the player variable. I've looked through the videos and tried a number of things but I can't seem to get the right answer.

What am I missing.

app.js
var player ="Jasmine";
index.html
<!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>
  document.write("Jasmine");
  </body>
</html>

1 Answer

Steven Parker
Steven Parker
217,443 Points

You just need to call the function and pass the variable to it by placing it in the parentheses:

document.write(player);

You'll still need the assignment you did for task 1, just add this after it.

Matthew Hemphill
Matthew Hemphill
1,082 Points

Aaaand that did it. Putting it in app.js and not overthinking it was what I needed. Thanks, Steven. I think several hours of staring at these lessons is my max. At least for now. My brain is goop.

Steven Parker
Steven Parker
217,443 Points

Glad I could help. Perhaps after a bit of rest you'll find things go smoother.

Happy coding!