Block Scope
Block Scope
Block scope means a let or const variable declared inside braces belongs to that block. Code after the block cannot read a variable that only exists inside the braces.
When a value needs to be assigned conditionally and used later, declare the variable before the block. Then assign it inside the branch that decides the value.
Your task: Create reviewMessage so the conditional can set it and the later log can read it.
Free with a JS Exercises account
Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.
By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.
Block Scope
Block scope means a let or const variable declared inside braces belongs to that block. Code after the block cannot read a variable that only exists inside the braces.
When a value needs to be assigned conditionally and used later, declare the variable before the block. Then assign it inside the branch that decides the value.
Your task: Create reviewMessage so the conditional can set it and the later log can read it.