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 Naming Variables

Justin Oswald
Justin Oswald
5,969 Points

Can Variable names not begin with an upper case letter? such as var Home_alone.

I wonder because of the use of Camel Case.

3 Answers

Hi Justin,

The first character must be a letter or an underscore. Variable names are case sensitive (Javascript is case-sensitive), meaning that Name, name and NAme are three different names. You can use a capital letter first but I think it is common to use camelCase

I hope i could help!

Phil

Justin Oswald
Justin Oswald
5,969 Points

So it would not be considered a syntax error but is uncommon. Thank you !

I'll take this further. It's best to follow best practices (in this case a common variable naming pattern) for various reasons. It may seem fine to create your owning naming pattern when working on a solo project. But you most likely will be working with a team of coders. That team will struggle to read your code and to remember your naming pattern when they have to collaborate with you or perhaps update your code on their own in the future. You might as well follow best practices now so that you don't develop bad coding habits.

Ian Salmon
Ian Salmon
Courses Plus Student 10,687 Points

and when you apply for a job, recruiters and devs will be looking at your code! It's very difficult to be a perfect fit for a team, but using these best practices will absolutely increase your chances of getting hired.

I'll also like to add onto this that whilst it is valid it is normally a Class which is defined with a capital, so as suggested variables are best to follow camelCase.