let
`let` declares a variable whose value you can change later.
let creates a named variable. Read it like this: let year = 2026; means "create year and store 2026 in it". Later you can assign a new value with year = 2027;.
The variable only exists inside the { } block where you declared it. That keeps it from changing in places you don't expect. You can't use it before the line that declares it, and you can't declare the same name twice in the same block.
TypeScript infers the type from the starting value: year becomes number, and the type checker refuses to assign a string to it. That check happens before running; when Node runs the code, the types are gone.
The course uses it from lesson 00.02 (let year = 2026;). Use let only when the value really changes; if it doesn't, const states your intent better.
Reach for it when: the value must change after you declare it, like a counter or an accumulator. If it won't change, use `const`.
Examples
Common mistake
let year = 2026; year = "2027";
Why: TypeScript inferred `number` from the starting value, so it won't accept a string later.
How to write it: Assign a number, or annotate a union if you truly need both: let year: number | string = 2026;.
Common mistake
let count = 1; let count = 2; console.log(count);
Why: You can't declare the same name with `let` twice in the same block.
How to write it: Declare it once and reassign: count = 2;.
