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
- Change
nameand watch the greeting follow. - Add
const year = 2026;and log it. - Try assigning to
name—name = "Ngọc";— and read the error. It says exactly what is wrong, which is the habit worth building here.