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
Gregory Dillon
Courses Plus Student 2,228 Pointsvariable naming conventions - non-capitalization vs capitalization
In the numbers module one of the code challenges is to write a var for the GermanyGDP.
why wouldn't the variable name begin with an non-capitalization format?
2 Answers
Chris Akers
2,527 PointsJavaScript itself does not prescribe any specific variable naming convention. Companies and projects are free to come up with code conventions to maintain internal consistency. Common userland conventions include only capitalizing the first character if it's a constructor, using all lowercase with underscore separators, etc.
In this instance since it was a proper noun I decided to capitalize the first character lest anyone see it as lack of respect for Germany. But yes, you're right. Normally I do not capitalize the first letter unless it's a constructor.
John Locke
15,479 PointsIt is normal for the first "word" of a variable to uncapitalized, and the subsequent "word" to be capitalized, but if the variable is an abbreviation (?), perhaps it is easier to understand what the variable is for...?
I do share your view, of maintaining a uniform convention for variables throughout.