diff --git a/snippets/stringToArrayOfWords.md b/snippets/stringToArrayOfWords.md index 4a7aa7c8a..01bd6eb8b 100644 --- a/snippets/stringToArrayOfWords.md +++ b/snippets/stringToArrayOfWords.md @@ -2,7 +2,7 @@ Converts a given string into an array of words -Use `String.split` to convert the string to an array. +Use String.split with a supplied pattern(defaults to non alpha as a regex) to convert to an Array of Strings and then filter to remove any empty strings. ```js const stringToArrayOfWords = (str, pattern = /[\W_]+/) => str.split(pattern).filter(Boolean)