Variables

Variables store values so you can use and reuse them later. JavaScript has three ways to declare one.

let and const

let declares a variable that can be reassigned later. const declares one that can't be reassigned once set — use it as your default unless you know the value needs to change.

Try it yourself
Console output

Naming rules

  • Names can contain letters, numbers, $, and _ — but can't start with a number.
  • Names are case-sensitive: score and Score are different variables.
  • By convention, JavaScript variables use camelCase — like firstName, not first_name.
Note: var is an older way to declare variables, from before let and const existed. You'll still see it in older code, but modern JavaScript almost always uses let and const instead.