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 Combining Strings

Create a variable named firstName and put your first name in the variable.

i dont get it

script.js
var firstName = prompt("Joel kab");
document.write("welcome");
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="script.js"></script>
</body>
</html>

3 Answers

var firstName = prompt();
document.write(firstName);

the first line will show a prompt window to enter your first name the second line will then write your first name you typed into the browser

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Joel,

I'm not sure where you're getting that code from, but it's not quite what the instructions are asking for?

Task 1 just wants a variable firstName with your name assigned to it. So, the prompt() method you are calling is not needed and actually will produce a syntax error, as you can't hard-code a value into that. prompt() expects user input, and the instructions don't want any user input.
The instructions also say nothing about calling the write() method on the document model. So, just delete that entire line.

I recommend reviewing the Video on assigning strings to variables and then giving the challenge another go.
Remember, instructions are very specific and must be followed exactly, or you will get a Bummer!. A good rule-of-thumb... If the instructions don't ask for it... don't put it in.

Keep Coding! :) :dizzy:

var firstName = 'Name'; Best example