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

I am using the document.write() statement but it is saying that i am not. i use document.write(player);

tell me what i am doing wrong please.

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>
  document.write();
<script src="app.js"></script>
 document.write()
</body>
</html>

3 Answers

The first task should be:

var player = 'Jasmine';

You didn't type the ; symbol

The second task you just add:

document.write(player);

One last thing, you're supposed to do everything inside the app.js tab, that's where the javascript code is placed, you used document.write() inside the index.html tab. It won't work because it's a different language.

  • Line 8 and 10 document.write(); is outside the script tags. Notice I have removed it.
  • Notice I have added document.write(); inside the script tags.
  • This piece of code var player = 'Jasmine' needs a ; a the end.
<!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">
      document.write(player);
    </script>
  </body>
</html>

i had the syntax correct. i just never put it inside the script. thanks

You are welcome :)