fix(curriculum): relax step 18 unknown key checks (#67130)

Co-authored-by: Huyen Nguyen <25715018+huyenltnguyen@users.noreply.github.com>
This commit is contained in:
Caio Bittencourt
2026-05-04 08:24:37 -03:00
committed by GitHub
parent 0e2af859d0
commit 10b8256ec0
@@ -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.