JavaScript How to count words in a string?

preview_player
Показать описание
We need the match method.
So we match the word boundaries globally in the string.
If the string has words it has word boundaries.
Two boundaries for each word.
Here you are.
We have got the word count.
Рекомендации по теме