Using functions in programming - 16

- Andrés Cruz

En español
Using functions in programming - 16

Functions are one of the fundamental pillars in any programming language and JavaScript is no exception; It allows us to execute a set of instructions to perform a task, calculate a value and in a nutshell we can easily reuse a set of instructions by using functions.

To create a function we have to use the reserved word function followed by the name of the function and to indicate the name of the function you have to take into consideration the same aspects that we talked about when we defined the name of a variable, do not start with numbers, do not use special characters, spaces, etc:

function multiplica() {
  console.log(5 * 2);
}

Here we simply create a function called multiply that is responsible for multiplying two values; so, if for some reason in life we need to multiply 5 * 2 multiple times in our program, we can perfectly create a function; but notice that we have only declared it, but at the moment it has not been executed, that is, the operation or set of operations, meaning instructions that we defined in it, have not been executed; to execute the function we simply have to place the name of the function and the parentheses:

multiply()
Andrés Cruz

Desarrollo con Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter

Andrés Cruz en Udemy

Acepto recibir anuncios de interes sobre este Blog.