← TypeScript Foundations
1 / 25
Lesson 1 — Basic types
Labels for your values
TypeScript is JavaScript plus types: labels that say what kind of value a variable holds. You write them after a colon — name: string for text, count: number for numbers, done: boolean for true/false. The TypeScript checker reads these labels before the code runs and warns you about mistakes, like adding a word to a number.
const city: string = "Oslo";
let year: number = 2026;
// year = "soon"; ← error: string is not a number
Why it matters: types catch typos and wrong values while you write, instead of after your users find them.
Want it another way?
Task
Declare count as a number with the value 5 so the program prints Alex and then 6.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
Test your knowledge
A quick 3-question quiz on this lesson — instant feedback.