<commit_before>###[Strings](../) > countWords

```js
countWords(str)
```

> Returns the number of words in a string.

- <code>str {String}</code>

The string to process.

####Example
```js
countWords('Hello world!        \nThis is a message     from outter\tspace.'); // => 9
countWords(''); // => 0
countWords(); // => Throws type error.
countWords(100); // => Throws type error.
```<commit_msg>Fix typo in example<commit_after>###[Strings](../) > countWords

```js
countWords(str)
```

> Returns the number of words in a string.

- <code>str {String}</code>

The string to process.

####Example
```js
countWords('Hello world!        \n This is a message     from outter\tspace.'); // => 9
countWords(''); // => 0
countWords(); // => Throws type error.
countWords(100); // => Throws type error.
```
{'fraction_non_alphanumeric': 0.20275344180225283, 'fraction_numerical': 0.012515644555694618, 'mean_word_length': 3.46927374301676, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4018989', 'n_tokens_mistral': 285, 'n_tokens_neox': 258, 'n_words': 82}