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

camel casing a declared variable

A task in JavaScript asks me to declare a variable and to code a camel cased version of it. I tried to figure out how to do it by looking up camel casing online and on YouTube but I still can't figure out how to do it. Trying to look at the syntax doesn't help either. Can someone explain to me how camel casing works?

1 Answer

Steven Parker
Steven Parker
243,318 Points

Camel case identifies words joined together using capitalization.

Here's the full definition from wikipedia:

Camel case (stylized as camelCase or CamelCase and also known as camel caps, or more formally as medial capitals) is the practice of writing compound words or phrases such that each word or abbreviation in the middle of the phrase begins with a capital letter, with no intervening spaces or punctuation.

Also, the JavaScript convention is to use a variation of camel case where the very first letter is not capitalized. This is sometimes called "mixed case" or "camel back" notation.

So, for example, a variable representing an amount of extra spacing might be called "extraSpacingAmount".

:warning: All publicly-contributed resources should be used with caution, but wikipedia is much more likely to contain reliable information than YouTube.