A solution for finding words started by a string. It works well on both front-end and back-end.
This implementation is inspired by the binary search algorithm. Like the famous algorithm, this solution uses the divide-and-conquer strategy and when it finds the first item, it searches for items on the left and right, stopping the loop when the first attempt fails.
npm install find-by-words
- wordsList
Array
- word
String
- caseSensitive
Boolean
(false
by default)
findByWords(['python', 'ruby', 'java', 'javascript', 'lua'], 'Java', true);
// output: ['java', 'javascript']