Lesson 5 of 5 · 8 minutes
Naming your variables well
The computer does not care whether a variable is named x or
amountToPay. People do.
A good name says what the box holds. price, tax,
and total make code easier to understand than a,
b, and c.
JavaScript names cannot contain spaces. Use camel case:
start with a small letter and begin each later word with a capital, as in
amountToPay.
Same result. Clear names make the purpose visible.
Loading the editor…
Rename p to price, t to tax, and x to total. Change every place each name appears.
Quick check
You can now choose names that make your code easy to read.