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

Develop with Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter

Andrés Cruz In Udemy

I agree to receive announcements of interest about this Blog.

!Courses from!

10$

On Udemy

There are 1d 13:53!


Udemy

!Courses from!

4$

In Academy

View courses

!Books from!

1$

See the books
¡Become an affiliate on Gumroad!