fix(curriculum): require space after keyword (#53185)

This commit is contained in:
Krzysztof G
2024-01-15 17:22:41 +01:00
committed by GitHub
parent cedc365eb8
commit 464e5e47ee
14 changed files with 23 additions and 23 deletions

View File

@@ -31,13 +31,13 @@ assert.match(code, /\s*const\s*res/)
You should assign `await fetch()` to your `res` variable.
```js
assert.match(code, /\s*const\s*res\s*=\s*await\s*fetch\(\s*(.*)\s*\)/);
assert.match(code, /\s*const\s*res\s*=\s*await\s+fetch\(\s*(.*)\s*\)/);
```
You should pass in the `forumLatest` constant to the `fetch` call.
```js
assert.match(code, /const\s*fetchData\s*=\s*async\s*\(\)\s*=>\s*{\s*try\s*{\s*const\s*res\s*=\s*await\s*fetch\(\s*forumLatest\s*\)\s*;?\s*}\s*catch\s*\(\s*err\s*\)\s*{\s*}\s*}/);
assert.match(code, /const\s*fetchData\s*=\s*async\s*\(\)\s*=>\s*{\s*try\s*{\s*const\s*res\s*=\s*await\s+fetch\(\s*forumLatest\s*\)\s*;?\s*}\s*catch\s*\(\s*err\s*\)\s*{\s*}\s*}/);
```
# --seed--

View File

@@ -22,7 +22,7 @@ assert.match(code, /const\s*data/);
You should assign `await res.json()` to the `data` variable.
```js
assert.match(code, /\s*const\s*data\s*=\s*await\s*res\.json\(\);?\s*/);
assert.match(code, /\s*const\s*data\s*=\s*await\s+res\.json\(\);?\s*/);
```
# --seed--

View File

@@ -14,7 +14,7 @@ Now create a `goCave` function that prints `Going to cave.` to the console.
You should use the `function` keyword to declare `goCave`.
```js
assert.match(code, /function goCave/);
assert.match(code, /function\s+goCave/);
```
`goCave` should be a function.

View File

@@ -14,7 +14,7 @@ Now create a `fightDragon` function that prints `Fighting dragon.` to the consol
You should use the `function` keyword to declare `fightDragon`.
```js
assert.match(code, /function fightDragon/);
assert.match(code, /function\s+fightDragon/);
```
`fightDragon` should be a function.

View File

@@ -14,19 +14,19 @@ Create three new empty functions called `buyHealth`, `buyWeapon`, and `goTown`.
You should declare `buyHealth` with the `function` keyword.
```js
assert.match(code, /function buyHealth/);
assert.match(code, /function\s+buyHealth/);
```
You should declare `buyWeapon` with the `function` keyword.
```js
assert.match(code, /function buyWeapon/);
assert.match(code, /function\s+buyWeapon/);
```
You should declare `goTown` with the `function` keyword.
```js
assert.match(code, /function goTown/);
assert.match(code, /function\s+goTown/);
```
`buyHealth` should be an empty function.

View File

@@ -14,7 +14,7 @@ Fighting each type of monster will use similar logic. Create an empty function c
You should use the `function` keyword to declare `goFight`.
```js
assert.match(code, /function\s*goFight/);
assert.match(code, /function\s+goFight/);
```
`goFight` should be an empty function.

View File

@@ -14,7 +14,7 @@ At the end of your code, create two empty functions named `attack` and `dodge`.
You should use the `function` keyword to declare `attack`.
```js
assert.match(code, /function\s*attack/);
assert.match(code, /function\s+attack/);
```
`attack` should be an empty function.
@@ -26,7 +26,7 @@ assert.match(attack.toString(), /attack\s*\(\s*\)\s*\{\s*\}/);
You should use the `function` keyword to declare `dodge`.
```js
assert.match(code, /function\s*dodge/);
assert.match(code, /function\s+dodge/);
```
`dodge` should be an empty function.

View File

@@ -18,13 +18,13 @@ Use `const` to create a variable named `audio` and set it equal to `new Audio()`
You should use the `new` keyword to create an instance of the `Audio` object.
```js
assert.match(code, /new\s*Audio\(\);?/)
assert.match(code, /new\s+Audio\(\);?/)
```
You should assign the `Audio` object to a constant named `audio`.
```js
assert.match(code, /const\s+audio\s*=\s*new\s*Audio\(\);?/)
assert.match(code, /const\s+audio\s*=\s*new\s+Audio\(\);?/)
```
# --seed--

View File

@@ -23,13 +23,13 @@ You should use a template literal to pass the `Invalid Input: ` message to the `
```js
// because it transforms template literals...
assert.match(code.split("function getCaloriesFromInputs")[1], /alert\(`Invalid Input: /);
assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(`Invalid Input: /);
```
You should use template literal syntax to display the first value in the `invalidInputMatch` array after the `Invalid Input: ` text.
```js
assert.match(code.split("function getCaloriesFromInputs")[1], /alert\(`Invalid Input: \${invalidInputMatch\[0\]}`\s*\)/);
assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(`Invalid Input: \${invalidInputMatch\[0\]}`\s*\)/);
```
# --seed--

View File

@@ -14,13 +14,13 @@ Still within your `if` block, set `isError` to `true` and return `null`.
After your `alert`, you should set `isError` to `true`.
```js
assert.match(code.split("function getCaloriesFromInputs")[1], /alert\(`Invalid Input: \${invalidInputMatch\[0\]}`\s*\);\s*isError\s*=\s*true/);
assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(`Invalid Input: \${invalidInputMatch\[0\]}`\s*\);\s*isError\s*=\s*true/);
```
After you modify `isError`, you should `return` the value `null`.
```js
assert.match(code.split("function getCaloriesFromInputs")[1], /alert\(`Invalid Input: \${invalidInputMatch\[0\]}`\s*\);\s*isError\s*=\s*true;?\s*return\s+null;?\s*\}/);
assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(`Invalid Input: \${invalidInputMatch\[0\]}`\s*\);\s*isError\s*=\s*true;?\s*return\s+null;?\s*\}/);
```
# --seed--

View File

@@ -22,13 +22,13 @@ assert.isFunction(decimalToBinary);
You should pass `input` as a parameter to your `decimalToBinary` function.
```js
assert.match(String(decimalToBinary), /function\s*decimalToBinary\s*\(\s*input\s*\)/);
assert.match(String(decimalToBinary), /function\s+decimalToBinary\s*\(\s*input\s*\)/);
```
The body of your `decimalToBinary` function should be empty.
```js
assert.match(String(decimalToBinary), /function\s*decimalToBinary\s*\(\s*input\s*\)\s*\{\s*\}/);
assert.match(String(decimalToBinary), /function\s+decimalToBinary\s*\(\s*input\s*\)\s*\{\s*\}/);
```
# --seed--

View File

@@ -22,13 +22,13 @@ assert.isFunction(countdown);
Your function `countdown` should accept `number` as a parameter.
```js
assert.match(String(countdown), /function\s*countdown\s*\(\s*number\s*\)/);
assert.match(String(countdown), /function\s+countdown\s*\(\s*number\s*\)/);
```
The body of your `countdown` function should be empty.
```js
assert.match(String(countdown), /function\s*countdown\s*\(\s*number\s*\)\s*\{\s*\}/);
assert.match(String(countdown), /function\s+countdown\s*\(\s*number\s*\)\s*\{\s*\}/);
```
# --seed--

View File

@@ -14,7 +14,7 @@ Then, remove the contents of your `decimalToBinary()` function. Leave the body o
The body of your `decimalToBinary()` function should be empty.
```js
assert.match(String(decimalToBinary), /function\s*decimalToBinary\s*\(\s*input\s*\)\s*\{\s*\}/);
assert.match(String(decimalToBinary), /function\s+decimalToBinary\s*\(\s*input\s*\)\s*\{\s*\}/);
```
# --seed--

View File

@@ -24,7 +24,7 @@ assert.isFunction(showAnimation);
The body of your `showAnimation` function should be empty.
```js
assert.match(String(showAnimation), /function\s*showAnimation\s*\(\s*\)\s*\{\s*\}/);
assert.match(String(showAnimation), /function\s+showAnimation\s*\(\s*\)\s*\{\s*\}/);
```
# --seed--