diff --git a/snippets_archive/isSimilar.md b/snippets_archive/isSimilar.md index a6c894361..7bb1b6745 100644 --- a/snippets_archive/isSimilar.md +++ b/snippets_archive/isSimilar.md @@ -8,14 +8,12 @@ Adapted from [here](https://github.com/forrestthewoods/lib_fts/blob/80f3f8c52db5 ```js const isSimilar = (pattern, str) => [...str].reduce( - (matchIndex, char) => - char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase() - ? matchIndex + 1 - : matchIndex, - 0 - ) === pattern.length - ? true - : false; + (matchIndex, char) => + char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase() + ? matchIndex + 1 + : matchIndex, + 0 + ) === pattern.length; ``` ```js diff --git a/test/isSimilar/isSimilar.js b/test/isSimilar/isSimilar.js index 7b0c9e77c..9fbeb204c 100644 --- a/test/isSimilar/isSimilar.js +++ b/test/isSimilar/isSimilar.js @@ -1,11 +1,9 @@ const isSimilar = (pattern, str) => [...str].reduce( - (matchIndex, char) => - char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase() - ? matchIndex + 1 - : matchIndex, - 0 - ) === pattern.length - ? true - : false; + (matchIndex, char) => + char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase() + ? matchIndex + 1 + : matchIndex, + 0 + ) === pattern.length; module.exports = isSimilar;