Word


Sample code


Generated by AI on 2023-06-12

ChatGPT, Bing, Bard: I asked each chatbot the same question:
* JS code that counts words in a given string

They all made this false assumption: words are separated by a single space. Moreover, they all ignored the punctuation marks. I asked them again:
* Not a good reply. The string may contain punctuation marks.

All three chatbots apologized. The new answer from two of them was not much different from the previous one. However, ChatGPT replied with the correct RegExp: /[\p{P}]+/u