>_BeginnerCoder
Donate

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.

Not clear enough?
Task

Create a const city and log: I live in <city>

← Back
Next →
🧠 Test your knowledge

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

Enjoying this lesson? Share it 👇

Keep going with JavaScript Foundations

Ready for more? These paid resources pick up where this lesson leaves off.

Some links on this page are affiliate links: we may earn a commission at no extra cost to you. We only recommend tools we believe are genuinely useful.