Why can the computer understand variables that were never created?

I was taking the multiple choice quiz for the Iterators lesson and was given the following code:

const randomNums = [1, 123, 25, 90, 3543, 42];

const foundElement = randomNums.findIndex(num => num > 200);

It is capable of understanding num even when it wasn’t’t declared. This has happened in other questions as well, when a variable is declared as a plural word, but yet it is able to comprehend the singular version of that variable name. Why is that?

This is just a simple naming convention for us developers, this has nothing to do with why the computer understands the variable.

we could even do:

const foundElement = randomNums.findIndex(reallyLongAndVeryUnlogicalVariableName => reallyLongAndVeryUnlogicalVariableName > 200);

and it would still work. But not very nice, is it?


num => num > 200

you declare a function. num is a parameter, parameters act as placeholders until they get there value from argument at function call. In this case, findIndex method is calling our function with values from the array.