What are functions

You can imagine functions as a block of code which is easily reusable and it is used to perform a specific task.

The use of functions allows us to modularize our code.

As we know, functions are generally defined as: function myFuncname (){my code}

The code inside the curly brackets is the code that will be executed when the function will be called.

Exercise

Follow the next links and fill the necessary areas. When finished, right-click, select inspect and click the "Sources" tab. Next, click the HTML file to see the code:

  Event calls function

  A function calls another function