educative.io

Incorrect solution and explanation provided

Incorrect explanation

we can store it any variable and ignore its use.


Course: https://www.educative.io/collection/10370001/6137836412600320
Lesson: https://www.educative.io/collection/page/10370001/6137836412600320/5377210228670464

Hi @Samrat_Saha,
Our callback function can ignore any number of consecutive parameters from end. In this example, we want to use the second parameter, i.e., the index of the element for which the callback is invoked. In such a case, we can ignore the third parameter by omitting it from the callback definition. If, at the same time, we don’t want to access the value of the array element (the first parameter), we can’t simply omit it from the parameter list and start at the second parameter like so: (ind) => console.log(ind) . In this case, the callback would be invoked with the array element value passed in as ind .

In JavaScript, when we want to ignore a parameter from the beginning or middle of a parameter list, we use a special parameter name, the _ symbol, instead of a parameter name. Accordingly, you’ll notice that we used _ as the first parameter, and ind as the second (and last) parameter. The callback will ignore the value of each array element (thanks to the _ symbol in its place), and accept the element index in the ind parameter.

We’ve updated the solution explanation in the lesson as well. You can refresh your lesson to see the changes.

Thanks!