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

cant move on...

I typed

var myname = "";

and it wont let me move on, I even tried it without the quotes or anything

scripts.js
var 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>
Matthew Caloger
Matthew Caloger
12,903 Points

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

You're creating a variable called "myname" while it's looking for "myName". in JavaScript, casing matters. the casing used in "myName" is called "camelCase" where the first 'word' of the variable name is lowercase, but every word after has a capitalized first letter. For example, thisIsACamelCaseVariableName. You'll see camelCase a lot, and I would recommend using it as it makes code easier to read.

3 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hey Hanna,

Challenges are very specific and extremely picky. It wants you to create a variable named myName (in camel-case), but you are using all lower-case.
If you fix that up, the task will pass.

Also, when just creating a variable and not assigning it anything, you just type the keyword (var) and the variable name.

var myName;

The task will pass with the syntax you have (once the correct name is there), but that line of code is technically assigning something to the variable (in this case, an empty string). So, while it will pass this challenge, it is different than just declaring a variable.

Keep coding! :) :dizzy:

Viktoria S
Viktoria S
6,773 Points

What was the exercise Hanna? Maybe the myname should be camel case myName or you just need to give a value to the variable: var myname = "Hanna";

Bolaji Salau
Bolaji Salau
7,980 Points

You can use the javascript console in the developer tools from your browser to see what is going on. If you are windows, you preview the file and do CTRL+ SHIFT+I to launch the console.