I am trying to make Wordle in React. For that I need a list of Strings. I am getting an array of strings from this API: https://random-word-api.herokuapp.com/all
The problem is that I don’t want every word. I only want words that has a length of 5. How do I remove all the strings that doesn’t have a length of 5 from the array?
>Solution :
Assuming you have an array of words, words, use Array#filter.
const fiveLetterWords = words.filter(w => w.length === 5)