0

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?

Emil
  • 107
  • 2
  • 12

1 Answers1

3

Assuming you have an array of words, words, use Array#filter.

const fiveLetterWords = words.filter(w => w.length === 5)
AKX
  • 152,115
  • 15
  • 115
  • 172