Call back function syntax


#1

Hi everyone, long time lurker first time poster so please forgive me if it’s a dumb question. I’ve noticed that the official solution drops the “s” in call back functions when referring to a previous array. Is there a reason for this? The output seems to be the same when I do include the “s”. for example:

const bigNumbers = [100, 200, 300, 400, 500];

// Create the smallNumbers array below
const smallNumbers = bigNumbers.map(bigNumbers => bigNumbers/100);

gives the same output as:

const bigNumbers = [100, 200, 300, 400, 500];

// Create the smallNumbers array below
const smallNumbers = bigNumbers.map(bigNumber => bigNumber/100);

conversely, if I write the function as:

const smallNumbers = bigNumbers.map(bigNumber => bigNumbers/100);

the output returns an array with [NaN].

My hunch is that by dropping the “s” we are not referring to the original array but making the distinction that the function is taking each element in the array and applying an argument to it before passing it to the iterator. Is this correct?


#2

the variable you define here:

map(bigNumber 

will get assigned the values from the list (map is taken care of this)

you could name this anything you like:

const smallNumbers = bigNumbers.map(whateverYouWant => whateverYouWant/100);

but dropping the s is logic, given you go from plural (array) to single (values from array one by one thanks to the loop)