Functions

What is a function?

A function is a block of code that you can name and that performs a specific task. You can run the block multiple times by using the name of the function. The definition of a function specifies its name and the data needed by the function to work.

What are parameters and arguments?

Parameters are the variables in the function that hold this kind of data. Arguments are the values for each of the function's parameters.

What is a function call?

To use a function, you call it. When you call a function, you must provide arguments.

What are functions used for?

Functions are used for allowing you to write code efficiently. When you need to perform an action more than once, wrap that code in a function and call it when you need it. When you need to change how the action is carried out, you can change the function's cod, and the improvement is applied everywhere.