Workshop › Text detective › Step 5 of 13
Double spaces, spaces at the ends and line breaks give empty "words". We trim the ends and split at any run of spaces.
```js
const words = box.value.trim().split(/\s+/)
```trim() removes spaces at the start and the end./\s+/ is a regular expression: \s is any space-like character (space, tab, line break), + means "one or more".Change the words line as shown.
Skills: Types and values
← Split into words An empty box has no words →