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 trialjoel kab
Courses Plus Student 440 PointsCreate a variable named firstName and put your first name in the variable.
i dont get it
var firstName = prompt("Joel kab");
document.write("welcome");
<!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
xghrtkl
1,759 Pointsvar 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
Treehouse Moderator 145,860 PointsHey 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! :)
Clarke Criddell
5,946 Pointsvar firstName = 'Name'; Best example