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

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

i dont get it

var firstName = prompt("Joel kab");
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
<script src="script.js"></script>

3 Answers

var firstName = prompt();

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
Jason Anders
Treehouse Moderator 145,627 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