Concept Flow - Variable scope (lexical scoping)
Start: Global environment
Define function
Call function
Look for variable in function environment
Found?
Use variable
Return value or error if not found
End
When a function runs, it first looks for variables inside itself. If not found, it looks outside in the environment where it was created, following the chain until found or error.