Explained solution and added alternate (#34718)
* Explained solution and added alternate Explained why the solution works and added an alternate, less elegant solution for comparison. * Removed last line per feedback
This commit is contained in:
committed by
Randell Dawson
parent
e0ce2301e6
commit
baed72fd3d
@ -7,6 +7,8 @@ Simply split the string to create a new array of words.
|
||||
|
||||
A simple regular expression can be used to achieve this result.
|
||||
|
||||
`/\W/` Matches any non-word character. This includes spaces and punctuation, but not underscores. It's equivalent to `/[^A-Za-z0-9_]/`. For more information about Regular Expressions, see the official [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions).
|
||||
|
||||
### Solution
|
||||
```javascript
|
||||
function splitify(str) {
|
||||
|
Reference in New Issue
Block a user