# Parameters of returning functions in JavaScript

You can pass parameters to the function calls we have studied. In the following example, the inner function expects a string as a parameter and prints it to the console:

`function func() { return function(str) { return str; }; }`

The second bracket corresponds to the internal function when called, which means that we pass the desired string to this second bracket:

`function func() { return function(str) { return str; }; } console.log( func()('!') ); // shows '!'`

Let's make both the first function take a parameter and the second one. And the result of the call will be the sum of these parameters:

`function func(num1) { return function(num2) { return num1 + num2; }; } console.log( func(1)(2) ); // shows 3`

Make the function `func`, which, when called like this: `func(2)(3)(4)`, will return the sum of the numbers passed to the parameters.

Make the function `func`, which, when called like this: `func(2)(3)(4)(5)()`, will return an array of the numbers passed in the parameters.

←→
↑
en ru