# Passing parameters to an asynchronous callback in JavaScript

Now let's make it so that input parameters can be passed to the asynchronous function. Let for example, as the first parameter of the `make` function, we will pass the index of the array element that we want to get as a result. For example, let's get the third array element:

`make(3, function(res) { console.log(res); // the third array element });`

Let's rewrite our `make` function code as described:

`function make(num, callback) { setTimeout(function() { let arr = [1, 2, 3, 4, 5]; callback(arr[num]); // we pass the array element as a result }, 3000); }`

Make the `make` function take two parameters: indices of one and the other array elements. Let this function return the sum of the specified elements as a result of an asynchronous operation.

← →
↑
en ru