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

javascript basics:

Use the document.write() function to print the contents of the player variable to the page.

I wrote this and it saids that is wrong

document.write("player");

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

2 Answers

Your code should look something like

var player = "Jasmine";
document.write(player);

No "player", the reason that this happened is because you are passing the string "player" no the what the variable player evaluate to.

I hope this help.

Rich Donnellan
Rich Donnellan
Treehouse Moderator 27,671 Points

I specifically avoided giving "the answer" to stimulate the brain activity of the OP. No benefit in doing the work for them.

I agree with you, but some people learn by looking at example. Some times it can be frustrating when you are stuck in a problem like this.

Rich Donnellan
Rich Donnellan
Treehouse Moderator 27,671 Points

Agreed; and I have done so recently. However, I feel this is not one of those times as this challenge is as basic as can be.

Thanks for the info, Daniel. I'm a visual learner, myself, and am still coming to grips with the terminology in programming. Thanks for laying it out.

Thank you Bryan.

Rich Donnellan
MOD
Rich Donnellan
Treehouse Moderator 27,671 Points

It is incorrect.

You are passing in the string "player", not the variable.