Different programming languages have different conventions for how to name variables.
In JavaScript we name variables using camel case. In camel case, all letters are lowercase unless we are starting a new word.
It's called camel case because the uppercase letters in the middle of the variable names look like the humps on a camel.
Using Camel Case
These are examples of how to take a descriptive name and turn it into camel case:
Original Descriptive Name | Camel Case Variable Name |
---|---|
Value | value |
Input String | inputString |
Number 1 | number1 |
Customer Age | customerAge |
Shopping Cart Item Count | shoppingCartItemCount |
User ID | userID |
Flight ETA | flightETA |
HTML Element | HTMLElement |
Consistency
Functions and arguments follow this same rule. Always use camel case.
Your code won't break if you use another naming convention, but it will look out of place to an experienced developer. All of JavaScript's built-in functions use camel case. Keep variable names consistent and they will be easier to read.
Practice
Look at the code in the editor. The variables should all be in camel case to keep things consistent. Fix the code by converting all values to camel case.
Remember that strings are not variable names, so you don't need to change the string arguments.