← Back to challenges

Get Word Count

JavaScriptHardstringsmathnumbers

Instructions

Create a function that takes a string and returns the word count. The string will be a sentence.

Examples

countWords("Just an example here move along") ➞ 6

countWords("This is a test") ➞ 4

countWords("What an easy task, right") ➞ 5

Notes

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Western Showdown