benjaminvr

Codecademy - Scope pollution

Jul 7th, 2021
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const satellite = 'The Moon';
  2. const galaxy = 'The Milky Way';
  3. let stars = 'North Star';
  4.  
  5. const callMyNightSky = () => {
  6.   stars = 'Sirius'; // scope pollution -- overwrites existing global value
  7.     return 'Night Sky: ' + satellite + ', ' + stars + ', ' + galaxy;
  8. };
  9.  
  10. console.log(callMyNightSky());
  11. console.log(stars);
Advertisement
Add Comment
Please, Sign In to add comment