mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
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:
+13
-4
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user