Naming Conventions
JavaScript does not have any specific rules for naming variables; however, other languages do. Naming conventions help your code stay fluent within the context of your program. This is important because you want to have consistency throughout your entire program. Below you will find general rules when naming your variables.
- Variables tend to start with a letter.
- Spaces are not allowed in variables
- Special characters such as “!,-,@” are not allowed in the name
- Digits are allowed but keep Rule number 1 in mind.
Example of valid names
user
total
output
results
Example of invalid names
Becky Johnson
output!
12Users
first-name
Variable names should clearly express how the variable is going to be used. For example, the following names are valid but not typically a good idea to use:
tuna = 32
TheResultsFromACalculationWithALongName = ((32 + x) / 5)
I always had a passion for the field of STEM (Science, Technology, Engineering, and Math) and I knew I wanted to do something to make a difference in the world. I just didn’t know where to start. I was an immigrant in a new country, grew up in a tough environment, and wasn’t sure how… Read More