O
O
One of Us2019-10-06 14:58:35
JavaScript
One of Us, 2019-10-06 14:58:35

What is the best way to find similar words (search tips)?

Hello!
I'm writing simple search tips in react + redux. I am just learning. In principle, everything is clear with React and Redax. I store the value from the input in the store and when I update the value, a new value is written to the store, and in addition, based on value, no more than five words should be selected from the array of words (Which is already initially in the store).
I don't know the best way to organize this. I can just filter through the array (e.g. by casting the words and value to toLowercase() and slice(0,4) to cut the array. But isn't that too much work, since the array is quite large).
Is there any easy way? I can write a big function where I put a counter, and I can complete it when I find 5 matching words. But is there any more elegant solution or not?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question