Files
30-seconds-of-code/test/fuzzySearch/fuzzySearch.js
2018-02-22 09:14:29 -08:00

6 lines
251 B
JavaScript

const fuzzySearch = (pattern, str) =>
[...str].reduce(
(matchIndex, char) => char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase() ? matchIndex + 1 : matchIndex, 0
) === pattern.length ? true : false;
module.exports = fuzzySearch;