Introduction
Block scope helps keep variables limited to a small area of code. This stops mistakes and keeps code neat.
When you want a variable to exist only inside an if statement or loop.
When you want to avoid changing a variable outside a small code block.
When you want to reuse the same variable name in different parts of your code safely.
When you want to keep temporary values hidden from the rest of your program.