CodePeek
Practice / ScopeBack to CodePeek

JavaScript Block scope: Inside voice

Puzzle 10 of 15 · Block scope

Follow let declarations with the same name inside and outside a block. Predict which binding each console log reads. Choose an output below, then check the explanation. No signup needed. Browse puzzles by topic →

Scope / Block scopeJavaScript
let name = "outer";
{
  let name = "inner";
  console.log(name);
}
console.log(name);

Predict the console output. Each line is a separate log.

What’s the output?

Choose the output

Starter puzzles 15