DEV Community

loading...

Discussion on: count number of word in string using javascript.

Collapse
delixx profile image
DeLiXx

or you do

str.split(" ").length

which is not only easier to read but also faster