Instantly share code, notes, and snippets.

View Object and Array Drills
View Objects
View Global Variables
Question 1.
A variable scope determines when variables can be assessed at different parts of the code. A variable in the global scope can be accessed anywhere in the code. On the other hand a variable in a block scope can only be accessed in the function it was defined in.
Question 2.
A global variable can lead to unexpected outcomes due to different parts of the code trying to use the same variable name. For example if a global variable was named xyz, but then a function creates another variable named xyz without using let, or const it can lead to many hard to fix bugs.
Question 3.
Strict mode prevent people from defining variables without using let or const. This stops people from creating global variables within their functions.
Question 4.
View Array and Loop
View Array 2
View Array
View Logic
View Number drills
View Strings