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 trial

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
231,271 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
231,271 Points

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

Happy coding!