If it’s better to avoid declaring variables in the global scope, then when would we declare them there?
You’d primarily only be declaring variables in the global scope if there are certain variables that you need to access throughout your code across seperate inner scopes. You just want to define these commonly access variables in your global scope. Any variables that use these global variables in their own context can be made in its own scope so it doesn’t have to be shared across different scopes. You’ll learn about making inner block scopes in the next exercise. Basically, create your variables as low down in your scope as you can, but not too low that you can’t use them elsewhere where they’re needed. Example: