Solutions are designed with increase level of complexity.
Create a function that will return the number of words in a text
(scroll down for solution)
If you are a code newbie, try to work on the solution on your own. After you finish it, or if you need help, please consult the provided solution.
Please provide alternative solutions in the comments below.
You can solve it using functional concepts or solve it using a different algorithm... or just solve it using the latest ES innovations.
By providing a new solution you can show code newbies different ways to solve the same problem.
To quickly verify this solution, copy the code above in this coding editor and press "Run".
Note: The solution was originally designed for codeguppy.com environment, and therefore is making use of
println. This is the almost equivalent of
console.login other environments. Please feel free to use your preferred coding playground / environment when implementing your solution.