ReferenceError: word is not defined


I’m working on an arrow function with the .filter() iterator:

let longFavoriteWords = favoriteWords.filter(word => word.length > 7)

This function returns SyntaxError: Identifier ‘longFavoriteWords’ has already been declared. Ands thats ok because it has already been declared.
But if it has been already been declared it means i can reference the variable without ‘let’. And when I do it:

longFavoriteWords = favoriteWords.filter(word => word.length > 7)

I get the error: ReferenceError: word is not defined.
As far as I know, ‘word’ is a function parameter and it doesn’t have to be declared.

I think it works anyway but I would like to know the reason of the error.


You’re giving us no context to work with. First, we should need the lesson page (link, please) and a bit more code to go on that just what you’ve given thus far. How about a full display of what you’ve got to this point?


Tranks for your reply @mtf

Link to the lesson page:


let favoriteWords = ['nostalgia', 'hyperbole', 'fervent', 'esoteric', 'serene'];

let longFavoriteWords = favoriteWords.filter(function(word) {
  return word.length > 7;

// Refactor the code above using arrow function syntax

let longFavoriteWords = favoriteWords.filter(word => word.length > 7);


When they say refactor it means adjust the code itself, or remove the old code.