Sobes.tech
Junior — Senior

Determine the number of words in a line in one pass

livecode

Task condition

It is necessary to implement a function that counts the number of words in a given string, passing through it only once.

Input example:

"Hello world from ChatGPT"

Expected result:

4