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 trialEDDY saqchez
635 Pointsdont know how to Create a variable named firstName and put your first name in the variable.
script
var firstName = prompt ('what is your first name');
Var = message
message + firstName;
document.write(message);
<!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>
Christopher Roelle
5,426 PointsChristopher Roelle
5,426 PointsSo first off
var firstName = prompt('What is your first name?');
will display a prompt to the user, and will be returned whatever the value the user types, and will store the returned value in a variable called firstName.Second the line
Var = message
is actually supposed to bevar message;
with a semicolon, and the equals should be after the variable name you are declaring, and var should be lowercased as JavaScript is a Case-sensitive language.third, the line
message + firstName;
should bemessage += firstName;
ormessage = message + firstName;
The way it is written currently isnt understood by the interpretter, so the first way I wrote it is shorthand for the second way I wrote it, which takes message and sets it equal to itself concattenated with the string of 'firstName'That should be all the errors you have, I hope this helps, and if you have any questions, just ask. Cheers!