Values and variables

Naming things, and the difference between let and const.

JavaScript works with values: numbers, strings of text, true and false, lists, objects. A variable is a name for one.

const name = "Mai";
let count = 0;

count = count + 1;

const means the name will not be pointed at anything else. let means it will. Reach for const first and change it to let only when you actually reassign — a reader then knows, at a glance, which names move.

Saying things out loud

console.log(...) prints. In this playground, anything you log appears in the page, so you can watch a value without opening developer tools.

console.log("count is", count);

Try it

  1. Change name and watch the greeting follow.
  2. Add const year = 2026; and log it.
  3. Try assigning to namename = "Ngọc"; — and read the error. It says exactly what is wrong, which is the habit worth building here.
Loading...
Values and variables — RunSnip