It is important to note that variables are case sensitive, meaning that the variable ‘myVariable’ is not the same as ‘myvariable’. Additionally, variables must be declared before they can be used, otherwise the program will throw an error. Once declared, variables can be used throughout the program to store and manipulate data.
Functions are reusable pieces of code which can take parameters and return values. They are like small programs within a larger program which can be used to accomplish specific tasks. Functions are declared with the keywords ‘function’ followed by the name of the function and then parentheses containing any parameters which will be passed into it. Inside of the function is a set of instructions which will be executed when the function is called.
Writing clean code is essential to writing efficient code—it helps the readability and maintenance by reducing the likelihood of bugs popping up in the future. To achieve this, one should always use consistent formatting (eg. indentation), use descriptive variable names, comment important sections of code, avoid global variables where possible, and use try/catch blocks for error handling.
Resources for Further Learning