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.