Scope of a variable

Attention: Our videos have subtitles in all partner languages. You can switch on subtitles in the youtube player by clicking the gear wheel and selecting your preferred language.

In this section we explain a small but important detail concerning functions and variables. We help you understand potential mistakes and prepare you for using variables inside of functions correctly. A variable that can be used in any part of the code is called a global variable. However, we don't want too many global variables in our code. That can be hard to manage and consume computer resources. The solution is to have variables that we can just use inside smaller pieces of code, local variables.