From 10b8256ec0277cda85b989c42a8d44a56bdd7afc Mon Sep 17 00:00:00 2001 From: Caio Bittencourt Date: Mon, 4 May 2026 08:24:37 -0300 Subject: [PATCH] fix(curriculum): relax step 18 unknown key checks (#67130) Co-authored-by: Huyen Nguyen <25715018+huyenltnguyen@users.noreply.github.com> --- .../69a9de82b435a1310aff57c2.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/curriculum/challenges/english/blocks/workshop-heritage-library-catalog/69a9de82b435a1310aff57c2.md b/curriculum/challenges/english/blocks/workshop-heritage-library-catalog/69a9de82b435a1310aff57c2.md index 4e19130c97d..100a8a6e7d0 100644 --- a/curriculum/challenges/english/blocks/workshop-heritage-library-catalog/69a9de82b435a1310aff57c2.md +++ b/curriculum/challenges/english/blocks/workshop-heritage-library-catalog/69a9de82b435a1310aff57c2.md @@ -18,20 +18,29 @@ Finally, use `continue` to skip the rest of the loop body. The `continue` statem You should check if `book.year` is equal to `"Unknown"`. ```js -assert.match(groupByDecade.toString(), /book\.year\s*===?\s*"Unknown"/); +assert.match(groupByDecade.toString(), /book\.year\s*===?\s*("|')Unknown\1/); ``` You should check if `grouped["Unknown"]` doesn't exist yet and initialize it as an empty array. ```js -assert.match(groupByDecade.toString(), /!\s*grouped\s*\[\s*"Unknown"\s*\]/); -assert.match(groupByDecade.toString(), /grouped\s*\[\s*"Unknown"\s*\]\s*=\s*\[\s*\]/); +const code = groupByDecade.toString(); +const existenceChecks = [ + /!\s*grouped\s*\[\s*("|')Unknown\1\s*\]/, + /!\s*Object\.hasOwn\s*\(\s*grouped\s*,\s*("|')Unknown\1\s*\)/, + /!\s*grouped\s*\.hasOwnProperty\s*\(\s*("|')Unknown\1\s*\)/, + /grouped\s*\[\s*("|')Unknown\1\s*\]\s*===?\s*undefined/, + /!\s*\(\s*("|')Unknown\1\s*in\s*grouped\s*\)/, +]; + +assert.isTrue(existenceChecks.some(re => re.test(code))); +assert.match(code, /grouped\s*\[\s*("|')Unknown\1\s*\]\s*=\s*\[\s*\]/); ``` You should push `book` into `grouped["Unknown"]`. ```js -assert.match(groupByDecade.toString(), /grouped\s*\[\s*"Unknown"\s*\]\s*\.push\s*\(\s*book\s*\)/); +assert.match(groupByDecade.toString(), /grouped\s*\[\s*("|')Unknown\1\s*\]\s*\.push\s*\(\s*book\s*\)/); ``` You should use `continue` to skip to the next iteration after handling an unknown year.