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

how do i name a variable

tried to write the named varable as var name = "noName";

just not sure what Im missing. Its been about a month since i could finally get back on. Probably just start over and go from there

scripts.js
var name = "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>

3 Answers

Adam Beer
Adam Beer
11,314 Points

Challenge Task 1 of 2

Create a variable named myName but don't put anything in it yet.

You wrote name to variable name, not myName, but don't put anything in it yet. So the myName variable value is nothing.

var myName ="";

honestly after looking at both of your answers i did a homer "doh" thanks.!

Adam Beer
Adam Beer
11,314 Points

You have not given anything now, but var myName expect a string value. So now you did not put value. Later it can be a string, boolean or number, like this

var myName;
Mike Hatch
Mike Hatch
14,940 Points

The instructions say to:

"Create a variable named sayName but don't put anything in it yet."

I'm halfing that one line of instruction line into two parts:

  1. Create a variable named sayName
  2. But don't put anything in it yet.

So basically you are declaring a variable without yet assigning it a value.