Codington
0 of 8 problems solved • 0%

Exercise prompt

Use a Block-Scoped Value

Variables declared with const or let inside a block exist only between that block's braces.

Example

if (true) { const status = "ready"; console.log(status); // outputs "ready" }

Predict the output

Two badge variables share a name but live in different scopes. Predict what is displayed inside and outside the block.

const score = 9; const badge = "Silver"; if (score >= 8) { const badge = "Gold"; console.log("Inside:", badge); } console.log("Outside:", badge);
What will this code print?