More Variables

You've already created several variables. You called one of them by a single-letter name: x. The others had more meaningful names: luckyNumber and negativeNumber. While it's easier to type x than luckyNumber, it's easier to understand what code is doing when variable names are more descriptive. In JavaScript, most programmers use "camel case" names: when you're smashing together several words to describe the value being stored:

  • omit spaces
  • the first word is lowercase
  • each subsequent word is capitalized

The capital letters make the word have humps, like a camel. You don't have to use camel case, but it makes longer names easier to read.

Let's create a few descriptive variables:

age = 12
grade = 7
heightInInches = 60

Feel free to use your own age, grade and height when setting these variables. For practice, confirm that you can recall the value of each.

Challenge: can you use height in inches to calculate height in centimeters (assuming 1 inch is equal to 2.54 centimeters)?

If you've created age, grade, and heightInInches variables and confirmed that you can retrieve their values, you're ready to click the ✓ button.