A variable declared at the top of a program or outside a function is considered a global scope variable.
The value of a global variable can be changed inside a function. It is a good practice to avoid using global variables because the value of a global variable can be changed in different areas of the program. It can introduce unknown results in the program.
A variable can also have a local scope. It can only be accessed within a function. The let keyword is block-scoped (the variable can be accessed only in the immediate block). And var keyword has function scope.
Remember no teacher, no book, no video tutorial, or no blog can teach you everything. As one said Learning is Journey and Journey never ends. Just collect some data from here and there, read it, learn it, practice it, and try to apply it. Don’t feel hesitant that you can’t do that or you don’t know this concept or that concept. Remember every programmer was passed from the path on which you are walking right now. Remember Every Master was Once a Beginner. Work hard and Give your best.
Jai Hind, Vande Mataram 🇮🇳