Recap

Grade 1, page 9 of 9. A one-minute read.

  • A variable is a named box that holds a value.
  • Create variables with let (can change) or const (locked, can't be reassigned).
  • Use const by default, and let only when the value needs to change.
  • var is the old way. Recognize it, but don't use it in new code.
  • = is the assignment operator. It means "put into," not "equals."
  • Only use let or const the first time. To change a let variable, just use its name.
  • Variable names use camelCase, can't start with a digit, can't contain spaces or hyphens, and can't be reserved words.
  • A variable with no value contains undefined. Using a variable that doesn't exist at all gives a ReferenceError.
  • JavaScript works out the right side of = first, so score = score + 10 means "add 10 to whatever's in score."

Reading is step one

CurlyScript turns these notes into a game: short questions, an explanation after every answer, and a test at the end of each grade. Free, with nothing to sign up for.

Start learning