Change plural of variable in a callback

Hi everyone,

Sorry for the cryptic title, I didn’t really know how else to say it !

In the code below, the method call .some uses the variable ‘words’.
But in the callback function it’s ‘word’ that is used, when it is not a variable that has been created ! And I thought since the beginning that you always have to use the exact same spelling… So is there a reason for this change ? Is it a mistake ? Does it make a difference in the futur if I keep using ‘words’ to not confuse myself ?

Thanks for illuminating me :smiley:

const words = ['unique', 'uncanny', 'pique', 'oxymoron', 'guise'];

// Something is missing in the method call below

console.log(words.some(word => {
  return word.length < 6;

// Use filter to create a new array
const interestingWords = words.filter((word) => {return word.length > 5});

console.log(interestingWords.every((word) => {return word.length > 5}));

It doesn’t have to be called word, it can be whatever variable name you want. Just like when you create a regular function, the name you give the parameter can be used in that block of code. It was named word to help illustrate that you’re dealing with one element of the array.

For example, all of these would produce the same output as yours:

const words = ['unique', 'uncanny', 'pique', 'oxymoron', 'guise'];

console.log(words.some(oneElementOfTheArray => {
  return oneElementOfTheArray.length < 6;

const interestingWords = words.filter((value) => {return value.length > 5});

console.log(interestingWords.every((arrayElementBeingUsed) => {return arrayElementBeingUsed.length > 5}));
1 Like

Oooh all right ! I thought I had to call the variable everytime, I didn’t think of it as a parameter.
Thank you, very helpful :slight_smile: