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

sean farrelly
sean farrelly
1,614 Points

create a variable name myname but don't put anything in it yet.

create a variable name myname but don't put anything in it yet

scripts.js
var message="myname" ;
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="scripts.js"></script>
</body>
</html>
Erik Nuber
Erik Nuber
20,629 Points

It would be the other way around but you are close

var myname = "";
sean farrelly
sean farrelly
1,614 Points

Thanks Erik for the reply yeah its var myName = ""; what i was doing wrong was not putting the capital N in name thanks for the help.....

4 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! Your code has a variable named "message" with a string assigned it to named "myname". What they want is the variable to be named myName. Give it another go! :sparkles:

sean farrelly
sean farrelly
1,614 Points

var myName = ""; don't for get to put the capital N in name .....

In javascript it is not required to assign a value to a variable when you declare, if you precede the name/identifier given to the variable with the keyword var. For example: var age;

When doing so, the data type of the variable is said to be undefined.