diff --git a/curriculum/challenges/english/blocks/workshop-sentence-analyzer/66e2f376df6f315ee81de81a.md b/curriculum/challenges/english/blocks/workshop-sentence-analyzer/66e2f376df6f315ee81de81a.md index c481ecb54f5..26ba0dbc327 100644 --- a/curriculum/challenges/english/blocks/workshop-sentence-analyzer/66e2f376df6f315ee81de81a.md +++ b/curriculum/challenges/english/blocks/workshop-sentence-analyzer/66e2f376df6f315ee81de81a.md @@ -88,8 +88,16 @@ function getWordCount(sentence) { return 0; } - const words = sentence.trim().split(/\s+/); - return words.length; + const words = sentence.trim().split(' '); + let count = 0; + + for (const word of words) { + if (word !== '') { + count++; + } + } + + return count; } --fcc-editable-region-- @@ -150,8 +158,16 @@ function getWordCount(sentence) { return 0; } - const words = sentence.trim().split(/\s+/); - return words.length; + const words = sentence.trim().split(' '); + let count = 0; + + for (const word of words) { + if (word !== '') { + count++; + } + } + + return count; } const wordCount = getWordCount("I love freeCodeCamp");