Https://www.codecademy.com/paths/web-development/tracks/web-dev-js-arrays-loops-objects/modules/learn-javascript-iterators/lessons/javascript-iterators/exercises/documentation

I am having trouble understanding how the computer knows to use the variable “words” and “word” as the same thing, as “word” is not defined. This makes no sense to me. I added S’s to the "word"s without them which had no effect on the result. When I removed the s from the "words"s with them, it gave an error. Does “word” have an inherent property in javascript? if so, the question was rather confusing, with no explanation. Any explanation for this oddity would be greatly appreciated. Here is the exercise code:

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});

// Make sure to uncomment the code below and fix the incorrect code before running it

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

1 Like

In these cases “word” is the value that is passed while the function executes.

You can also write the above like this:

interestingWords.every((x) => {return x.length > 5})

The “word” is basically just a variable name, similar to this:

function(word) {
    return word.length > 5;
}
2 Likes

Thank you so much!! This totally cleared up the confusion I was having with this topic. Hopefully it helps others too!