Variables declared with const or let inside a block exist only between that block's braces.
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);