From 6df66051dddaf33b06f5a9a064a176ea3d9d82c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Val=C3=A9rie?= Date: Mon, 12 Jan 2026 15:15:44 +0100 Subject: [PATCH] fix(curriculum): replacing regex with loop in "Build a Sentence Analyzer" step 8 (#65056) --- .../66e2f376df6f315ee81de81a.md | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) 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");