

All work and no play makes Jack a dull boy.
:max_bytes(150000):strip_icc()/CustomizeStatusBar-2daa275d472f4bedba1ef58358be1ba9.jpg)
Var str = "All work and no play makes Jack a dull boy. This is the fastest at 111,037 ops/s ☒.86% fastest If anyone has any ideas on how to improve it, or cleaner / more efficient - then please add you 2 cents!

Sometimes gets counted as 0 x words, and other functions only count it as 1 x word, instead of 5 x words) Ignores all leading and trailing white spacesĬounts a single-letter followed by a new line, as a word - which I've found some of the suggestions given on this page don't count, for example: (some other suggestions I've tried count each example above as only 1 x word) Its able to recognise all of the following as separate words:Ībc/abc/abc = 3 words (works with forward and backward slashes), Var countWordsBySpaces = passedString.split(' ').length From Count number of words in string using JavaScript function countWords(str) /gi, ' ')
