Deviopath › JavaScript

Count Words

Easy · Strings

Write a function countWords that returns how many words are in a sentence.

Words are separated by one or more spaces, and there may be extra spaces at the start or end. An empty or all-space string has 0 words.

Next: Largest Number