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

variable Name

i have question on javascript variable . since we are saying that a variable is a container or a box given a name that we can refer to when we want to use a property but my question is when naming is it possible for a class of cats giving it a variable name of dogs , that wont they cause some confusion or wont they affect anything in my codding for example below is it okay to code like this ?

var carTypes = "dogs"

or to place numbers on a variable container of not numbers

2 Answers

Yes, the code in your example would work fine. Variable names in JavaScript (and all other languages I know of) are entirely arbitrary, there are no hard rules that restrict the names to something that makes logical sense. Though it is of course considered bad practice to make the variable names contradictory to what is stored in them, exactly due to the fact that it makes the code confusing to read and understand.

thank you Andren , i was thinking that it might cause the programm error .. thank you a lot Again