BeginnerCoder

Lesson 2 — let and const

let and const

Both create variables. Use let when the value will change later, and const when it should stay fixed. Prefer const by default — it prevents accidental changes.

Why it matters: choosing const makes your intent clear and catches bugs where a value changes by mistake.

Watch out: a const cannot be reassigned, so use let for counters and running totals.

Want it another way?
Task

Create a const city = "Paris" and log: I live in Paris

Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.