Frontend to darmowy bonus w CodeMentor AI — głównym produktem jest Python. Zarejestruj się, aby zapisać postępy i odblokować wszystkie 299 lekcji Frontend + 1,100+ lekcji Python.Zarejestruj się — za darmo
ZadanieDeclare three names: const APP_NAME set to 'CodeMentor', let counter set to 0, and inside a separate { } block use let inside set to 'private'. After the block, log APP_NAME, counter, and a literal string 'done' (do not log 'inside' — that should not be in scope).
let i const: nigdy nie używaj var
75 XP6 minFREE
Teoria
Two ways to name a value in 2026
const PI = 3.14; // I'm never reassigning this let counter = 0; // I will reassign this counter = counter + 1; // OK
Rules of thumb that hold up in production:
- Reach for `const` first. If you're not planning to reassign, use
const. It's the safer default. - Use `let` when the value genuinely changes — a loop counter, a "current" pointer, a value built up step by step.
- Never use `var`. It exists for backward compatibility.
varignores block scope, leaks into surrounding functions, and is hoisted in ways that hide bugs. If you see it in code from before 2017, that's why.
const doesn't mean immutable
A common surprise:
const user = { name: "Anna" };
user.name = "Boris"; // OK, the OBJECT is mutated
user = {}; // ERROR, the BINDING can't be reassignedconst locks the binding — what variable name points to. It doesn't freeze the value inside. Object.freeze() is the next-level lock if you need that.
Block scope, not function scope
if (true) {
let inner = 10;
}
console.log(inner); // ReferenceError: inner is not definedThe {} braces are the boundary. var would have leaked inner to the surrounding function. let doesn't.
Podgląd na żywo
console output appears here…