updated function
This commit is contained in:
@ -6,8 +6,8 @@ First create an array of dirt that you want to remove from the string. Then repl
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
const stringToArrayOfWords = str => {
|
const stringToArrayOfWords = str => {
|
||||||
[".", ",", "?", "!", "& ", "(", ")", "[", "]"].map(d => str = str.replace(d, ""));
|
[".", ",", "?", "!", "& ", "(", ")", "[", "]"].map(d => str = str.split(d).join(""));
|
||||||
return str.split(" ");
|
return str.split(/[\W_]+/);
|
||||||
}
|
}
|
||||||
|
|
||||||
// stringToArrayOfWords("I love javaScript!!") -> ["I", "love", "javaScript"]
|
// stringToArrayOfWords("I love javaScript!!") -> ["I", "love", "javaScript"]
|
||||||
|
|||||||
Reference in New Issue
Block a user