Scope- Scope Pollution

Having too many global variables can cause problems in a program. When you declare global variables, they go to the global namespace, which allows the variables to be accessible from anywhere in the program. Variables remain in the global namespace until the program finishes, which means that the global namespace can fill very quickly. When we have too many global variables in the global namespace, or we reuse variables across different scopes, we have what’s known as scope pollution. In the following video, we will take a look at scope pollution so that we will know how to avoid it.


  1. Click the play button to watch the video lesson.
  2. Watch the lesson as many times as needed.
  3. Code along with the instructor using the integrated code editor in the center of your screen.
  4. You can use the Run button beneath the code editor to test your code.
  5. Output from the code that you have written will appear in the panel on the right side of your screen.

If you get stuck or need assistance, you can click the button below to connect with a tutor. 

For additional questions or technical support, email