Being able to accurately and efficiently filter search results based on a user’s input is vital for ensuring a positive and effective user experience.
A common way to achieve this is simply to use JavaScript’s .filter() function and check if any of the elements .includes() the user’s input.
But by implementing regex to a search function, we can provide a better and accurate result to the user even if there is any spelling mistakes.