# Named functions-parameters in JavaScript

Functions that are passed as parameters do not have to be anonymous.

Let's make them like a Function Declaration. Let's name the first function `get1`, and the second - `get2`:

`function get1() { return 1; } function get2() { return 2; }`

Let's pass the names of the functions `get1` and `get2` to the parameters of the function `test` (that is, their source code, not the result):

`function get1() { return 1; } function get2() { return 2; } test(get1, get2); // shows 3 function test(func1, func2) { console.log( func1() + func2() ); }`

Let's change it to Function Expression:

`let get1 = function() { return 1; } let get2 = function() { return 2; } test(get1, get2); // shows 3 function test(func1, func2) { console.log( func1() + func2() ); }`

Make the function `test` that takes `3` functions as parameters and returns the sum of the results of the passed functions.

Make `3` functions, declaring them as a Function Declaration and naming them `func1`, `func2` and `func3`. Let the first function return `1`, the second return `2`, and the third return `3`. Pass these functions as a parameters to the `test` function from the previous task.

Modify the previous task so that the functions are declared as Function Expressions with the same names.

← →
↑
en ru