From 7c51f55e84cf61a46b83e6d2150c86cfe7963035 Mon Sep 17 00:00:00 2001 From: Rohit Tanwar <31792358+kriadmin@users.noreply.github.com> Date: Thu, 22 Feb 2018 09:30:13 +0530 Subject: [PATCH] Update fuzzySearch.md --- snippets/fuzzySearch.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/snippets/fuzzySearch.md b/snippets/fuzzySearch.md index d384e5b41..a4cb51430 100644 --- a/snippets/fuzzySearch.md +++ b/snippets/fuzzySearch.md @@ -1,14 +1,14 @@ ### fuzzySearch -Determines if the `patrn` matches with `str` +Determines if the `pattern` matches with `str` -Loops through `str` and determines if it contains all characters of `patrn` and in the correct order. Both the strings are converted to lower case. +Loops through `str` and determines if it contains all characters of `pattern` and in the correct order. Both the strings are converted to lower case. -Taken from [here](https://github.com/forrestthewoods/lib_fts/blob/80f3f8c52db53428247e741b9efe2cde9667050c/code/fts_fuzzy_match.js#L18). +Adapted from [here](https://github.com/forrestthewoods/lib_fts/blob/80f3f8c52db53428247e741b9efe2cde9667050c/code/fts_fuzzy_match.js#L18). ``` js const fuzzySearch = (pattern, str) => [...str].reduce( - (acc, char) => char.toLowerCase() === (pattern[acc] || '').toLowerCase() ? acc + 1 : acc, 0 + (matchIndex, char) => char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase() ? matchIndex + 1 : matchIndex, 0 ) === pattern.length ? true : false; ```