mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-20 12:03:11 -04:00
fix(curriculum): change any character to literal dot (#53246)
This commit is contained in:
@@ -16,7 +16,7 @@ For now, each recursive call prints the `rods` dictionary without performing any
|
||||
You should remove the last element from the `rods[source]` list and append it to the `rods[target]` list before the `print` call.
|
||||
|
||||
```js
|
||||
({ test: () => assert.match(code, /move\(\s*n\s*-\s*1\s*,\s*source\s*,\s*auxiliary\s*,\s*target\s*\)\s+rods\[\s*target\s*\].append\(\s*rods\[\s*source\s*\].pop\(\s*\)\s*\)/) })
|
||||
({ test: () => assert.match(code, /move\(\s*n\s*-\s*1\s*,\s*source\s*,\s*auxiliary\s*,\s*target\s*\)\s+rods\[\s*target\s*\]\.append\(\s*rods\[\s*source\s*\]\.pop\(\s*\)\s*\)/) })
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -14,7 +14,7 @@ Before appending the last element to the target, add a comment saying `move the
|
||||
You should add a comment with the provided text before `rods[target].append(rods[source].pop())`.
|
||||
|
||||
```js
|
||||
({ test: () => assert.match(code, /move\(\s*n\s*-\s*1\s*,\s*source\s*,\s*auxiliary\s*,\s*target\s*\)\s+#\s*move\sthe\snth\sdisk\sfrom\ssource\sto\starget\s+(?=rods\[\s*target\s*\].append\(\s*rods\[\s*source\s*\].pop\(\s*\)\s*\))/) })
|
||||
({ test: () => assert.match(code, /move\(\s*n\s*-\s*1\s*,\s*source\s*,\s*auxiliary\s*,\s*target\s*\)\s+#\s*move\sthe\snth\sdisk\sfrom\ssource\sto\starget\s+(?=rods\[\s*target\s*\]\.append\(\s*rods\[\s*source\s*\]\.pop\(\s*\)\s*\))/) })
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -28,7 +28,7 @@ assert.match(calculate.toString(), /array\.map\(\)/);
|
||||
You should assign the result of your `.map()` call to your `numbers` variable.
|
||||
|
||||
```js
|
||||
assert.match(calculate.toString(), /numbers\s*=\s*array.map()/);
|
||||
assert.match(calculate.toString(), /numbers\s*=\s*array\.map()/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -30,7 +30,7 @@ assert.match(calculate.toString(), /numbers\.filter\(\)/)
|
||||
You should assign the result of `numbers.filter()` to the `filtered` variable.
|
||||
|
||||
```js
|
||||
assert.match(calculate.toString(), /filtered\s*=\s*numbers.filter\(\)/);
|
||||
assert.match(calculate.toString(), /filtered\s*=\s*numbers\.filter\(\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -20,7 +20,7 @@ assert.match(code, /\s*const\s+thousands\s*=/);
|
||||
Your should assign `Math.floor(views / 1000)` to your `thousands` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /\s*const\s+thousands\s*=\s*Math.floor\(views\s*\/\s*1000\)\s*/);
|
||||
assert.match(code, /\s*const\s+thousands\s*=\s*Math\.floor\(views\s*\/\s*1000\)\s*/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -28,7 +28,7 @@ assert.match(code, /const\s+url\s*=\s*`[\s\S]*`/);
|
||||
You should have the value of `${forumCategoryUrl}${selectedCategory.className}/${id}` inside your template literal.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+url\s*=\s*`\$\{forumCategoryUrl\}\$\{selectedCategory.className\}\/\$\{id\}`/);
|
||||
assert.match(code, /const\s+url\s*=\s*`\$\{forumCategoryUrl\}\$\{selectedCategory\.className\}\/\$\{id\}`/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -24,7 +24,7 @@ assert.match(code, /const\s+forumLatest\s*=/);
|
||||
You should assign `https://forum-proxy.freecodecamp.rocks/latest` to your `forumLatest` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+forumLatest\s*=\s*('|")https:\/\/forum-proxy.freecodecamp.rocks\/latest\1\s*/);
|
||||
assert.match(code, /const\s+forumLatest\s*=\s*('|")https:\/\/forum-proxy\.freecodecamp\.rocks\/latest\1\s*/);
|
||||
```
|
||||
|
||||
You should declare a `forumTopicUrl` variable with `const`.
|
||||
@@ -36,7 +36,7 @@ assert.match(code, /const\s+forumTopicUrl\s*=/);
|
||||
You should assign `https://forum.freecodecamp.org/t/` to your `forumTopicUrl` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+forumTopicUrl\s*=\s*('|")https:\/\/forum.freecodecamp.org\/t\/\1\s*/);
|
||||
assert.match(code, /const\s+forumTopicUrl\s*=\s*('|")https:\/\/forum\.freecodecamp\.org\/t\/\1\s*/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -22,7 +22,7 @@ assert.match(code, /const\s+forumCategoryUrl\s*=/);
|
||||
You should assign `https://forum.freecodecamp.org/c/` to your `forumCategoryUrl` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+forumCategoryUrl\s*=\s*('|")https:\/\/forum.freecodecamp.org\/c\/\1\s*/);
|
||||
assert.match(code, /const\s+forumCategoryUrl\s*=\s*('|")https:\/\/forum\.freecodecamp\.org\/c\/\1\s*/);
|
||||
```
|
||||
|
||||
You should declare an `avatarUrl` variable with `const`.
|
||||
@@ -34,7 +34,7 @@ assert.match(code, /const\s+avatarUrl\s*=/);
|
||||
You should assign `https://sea1.discourse-cdn.com/freecodecamp` to your `avatarUrl` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+avatarUrl\s*=\s*('|")https:\/\/sea1.discourse-cdn.com\/freecodecamp\1\s*/);
|
||||
assert.match(code, /const\s+avatarUrl\s*=\s*('|")https:\/\/sea1\.discourse-cdn\.com\/freecodecamp\1\s*/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -26,13 +26,13 @@ assert.isFunction(goCave);
|
||||
You should have a `console.log("Going to cave.");` line in your code.
|
||||
|
||||
```js
|
||||
assert.match(code, /console.log\(('|")Going to cave\.\1\)/);
|
||||
assert.match(code, /console\.log\(('|")Going to cave\.\1\)/);
|
||||
```
|
||||
|
||||
Your `console.log("Going to cave.");` line should be inside your `goCave` function.
|
||||
|
||||
```js
|
||||
assert.match(goCave.toString(), /console.log\(('|")Going to cave\.\1\)/);
|
||||
assert.match(goCave.toString(), /console\.log\(('|")Going to cave\.\1\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -26,13 +26,13 @@ assert.isFunction(fightDragon);
|
||||
You should have a `console.log("Fighting dragon.");` line in your code.
|
||||
|
||||
```js
|
||||
assert.match(code, /console.log\(('|")Fighting dragon\.\1\)/);
|
||||
assert.match(code, /console\.log\(('|")Fighting dragon\.\1\)/);
|
||||
```
|
||||
|
||||
Your `console.log("Fighting dragon.");` line should be inside your `fightDragon` function.
|
||||
|
||||
```js
|
||||
assert.match(fightDragon.toString(), /console.log\(('|")Fighting dragon\.\1\)/);
|
||||
assert.match(fightDragon.toString(), /console\.log\(('|")Fighting dragon\.\1\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -23,7 +23,7 @@ When a player clicks your `Go to store` button, you want to change the buttons a
|
||||
You should not have a `console.log("Going to store.");` line in your code.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /console.log\(('|")Going to store\.\1\)/);
|
||||
assert.notMatch(code, /console\.log\(('|")Going to store\.\1\)/);
|
||||
```
|
||||
|
||||
You should use dot notation to access the `innerText` property of `button1`.
|
||||
@@ -35,7 +35,7 @@ assert.match(code, /button1\.innerText/);
|
||||
You should not use `let` or `const` to access the `innerText` property of `button1`.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /(let|const)\s+button1.innerText/);
|
||||
assert.notMatch(code, /(let|const)\s+button1\.innerText/);
|
||||
```
|
||||
|
||||
You should update the `innerText` property of `button1` to be `Buy 10 health (10 gold)`.
|
||||
|
||||
@@ -20,7 +20,7 @@ assert.match(code, /button2\.innerText/);
|
||||
You should not use `let` or `const` to access the `innerText` property of `button2`.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /(let|const)\s+button2.innerText/);
|
||||
assert.notMatch(code, /(let|const)\s+button2\.innerText/);
|
||||
```
|
||||
|
||||
You should update the `innerText` property of `button2` to be `Buy weapon (30 gold)`.
|
||||
@@ -44,7 +44,7 @@ assert.match(code, /button3\.innerText/);
|
||||
You should not use `let` or `const` to access the `innerText` property of `button3`.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /(let|const)\s+button3.innerText/);
|
||||
assert.notMatch(code, /(let|const)\s+button3\.innerText/);
|
||||
```
|
||||
|
||||
You should update the `innerText` property of `button3` to be `Go to town square`.
|
||||
|
||||
@@ -22,7 +22,7 @@ assert.match(code, /button1\.onclick/);
|
||||
You should not use `let` or `const` to access the `onclick` property of `button1`.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /(let|const)\s+button1.onclick/);
|
||||
assert.notMatch(code, /(let|const)\s+button1\.onclick/);
|
||||
```
|
||||
|
||||
You should set the `onclick` property of `button1` to be `buyHealth`.
|
||||
@@ -46,7 +46,7 @@ assert.match(code, /button2\.onclick/);
|
||||
You should not use `let` or `const` to access the `onclick` property of `button2`.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /(let|const)\s+button2.onclick/);
|
||||
assert.notMatch(code, /(let|const)\s+button2\.onclick/);
|
||||
```
|
||||
|
||||
You should set the `onclick` property of `button2` to be `buyWeapon`.
|
||||
@@ -70,7 +70,7 @@ assert.match(code, /button3\.onclick/);
|
||||
You should not use `let` or `const` to access the `onclick` property of `button3`.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /(let|const)\s+button3.onclick/);
|
||||
assert.notMatch(code, /(let|const)\s+button3\.onclick/);
|
||||
```
|
||||
|
||||
You should set the `onclick` property of `button3` to be `goTown`.
|
||||
|
||||
@@ -20,7 +20,7 @@ assert.match(code, /text\.innerText/);
|
||||
You should not use `let` or `const` to access the `innerText` property of `text`.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /(let|const)\s+text.innerText/);
|
||||
assert.notMatch(code, /(let|const)\s+text\.innerText/);
|
||||
```
|
||||
|
||||
You should update the `innerText` property of `text` to be `You enter the store.`.
|
||||
|
||||
@@ -27,7 +27,7 @@ assert.isAbove(split.indexOf('else'), split.indexOf('if'));
|
||||
You should set `text.innerText` to `You do not have enough gold to buy a weapon.`.
|
||||
|
||||
```js
|
||||
assert.match(buyWeapon.toString(), /text.innerText\s*=\s*('|")You do not have enough gold to buy a weapon.\1/);
|
||||
assert.match(buyWeapon.toString(), /text\.innerText\s*=\s*('|")You do not have enough gold to buy a weapon.\1/);
|
||||
```
|
||||
|
||||
Your `else` statement should set `text.innerText` to `You do not have enough gold to buy a weapon.`.
|
||||
|
||||
@@ -16,7 +16,7 @@ Inside your `attack` function, change your `health -= monsters[fighting].level;`
|
||||
You should update your `health` line to be `health -= getMonsterAttackValue(monsters[fighting].level);`.
|
||||
|
||||
```js
|
||||
assert.match(attack.toString(), /health\s*-=\s*getMonsterAttackValue\(monsters\[fighting\].level\)/);
|
||||
assert.match(attack.toString(), /health\s*-=\s*getMonsterAttackValue\(monsters\[fighting\]\.level\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -22,13 +22,13 @@ assert.match(code, /const\s+hit/);
|
||||
You should use the equation `(level * 5) - (Math.floor(Math.random() * xp))`.
|
||||
|
||||
```js
|
||||
assert.match(getMonsterAttackValue, /(level\s*\*\s*5)\s*-\s*(Math.floor\(Math.random\(\)\s*\*\s*xp\))/);
|
||||
assert.match(getMonsterAttackValue, /(level\s*\*\s*5)\s*-\s*(Math\.floor\(Math\.random\(\)\s*\*\s*xp\))/);
|
||||
```
|
||||
|
||||
You should set `hit` to the value of `(level * 5) - (Math.floor(Math.random() * xp))`.
|
||||
|
||||
```js
|
||||
assert.match(code, /hit\s*=\s*\(level\s*\*\s*5\)\s*-\s*\(Math.floor\(Math.random\(\)\s*\*\s*xp\)\)/);
|
||||
assert.match(code, /hit\s*=\s*\(level\s*\*\s*5\)\s*-\s*\(Math\.floor\(Math\.random\(\)\s*\*\s*xp\)\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -30,7 +30,7 @@ assert.match(pick.toString(), /while\s*\(/);
|
||||
Your `while` loop should run while `numbers.length < 10`.
|
||||
|
||||
```js
|
||||
assert.match(pick.toString(), /while\s*\(\s*numbers.length\s*<\s*10\s*\)/);
|
||||
assert.match(pick.toString(), /while\s*\(\s*numbers\.length\s*<\s*10\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -22,7 +22,7 @@ assert.match(code, /\{\s*name\s*,\s*id\s*,\s*price\s*,\s*category\s*\}/);
|
||||
Your destructuring should be the first parameter of the callback function.
|
||||
|
||||
```js
|
||||
assert.match(code, /products.forEach\(\s*\(\s*\{\s*name\s*,\s*id\s*,\s*price\s*,\s*category\s*\}\s*\)\s*=>/);
|
||||
assert.match(code, /products\.forEach\(\s*\(\s*\{\s*name\s*,\s*id\s*,\s*price\s*,\s*category\s*\}\s*\)\s*=>/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -32,7 +32,7 @@ assert.match(code, /clearCartBtn\.addEventListener\(\s*('|"|`)click\1\s*,/);
|
||||
Your event listener should take `cart.clearCart.bind(cart)` as the callback.
|
||||
|
||||
```js
|
||||
assert.match(code, /clearCartBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*cart\.clearCart\s*.bind\(\s*cart\s*\)\s*\)/);
|
||||
assert.match(code, /clearCartBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*cart\.clearCart\s*\.bind\(\s*cart\s*\)\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -16,19 +16,19 @@ Also, set the `audio.title` property equal to `song.title`. This tells the audio
|
||||
You should not modify the exist `playSong` function and its content.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+playSong\s*=\s*\(id\)\s*=>\s*\{\s*const\s+song\s*=\s*userData\?\.songs\.find\(\(song\)\s=>\s*song.id\s===\s*id\);?/)
|
||||
assert.match(code, /const\s+playSong\s*=\s*\(id\)\s*=>\s*\{\s*const\s+song\s*=\s*userData\?\.songs\.find\(\(song\)\s=>\s*song\.id\s===\s*id\);?/)
|
||||
```
|
||||
|
||||
You should set `audio.src` to `song.src`.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+playSong\s*=\s*\(id\)\s*=>\s*\{\s*const\s+song\s*=\s*userData\?\.songs\.find\(\(song\)\s=>\s*song.id\s===\s*id\);?\s*audio\.src\s*=\s*song\.src;?/)
|
||||
assert.match(code, /const\s+playSong\s*=\s*\(id\)\s*=>\s*\{\s*const\s+song\s*=\s*userData\?\.songs\.find\(\(song\)\s=>\s*song\.id\s===\s*id\);?\s*audio\.src\s*=\s*song\.src;?/)
|
||||
```
|
||||
|
||||
You should set `audio.title` to `song.title`.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+playSong\s*=\s*\(id\)\s*=>\s*\{\s*const\s+song\s*=\s*userData\?\.songs\.find\(\(song\)\s=>\s*song.id\s===\s*id\);?\s*audio\.src\s*=\s*song\.src;?\s*audio\.title\s*=\s*song\.title;?\s*\};?/)
|
||||
assert.match(code, /const\s+playSong\s*=\s*\(id\)\s*=>\s*\{\s*const\s+song\s*=\s*userData\?\.songs\.find\(\(song\)\s=>\s*song\.id\s===\s*id\);?\s*audio\.src\s*=\s*song\.src;?\s*audio\.title\s*=\s*song\.title;?\s*\};?/)
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -24,7 +24,7 @@ Chain the `join()` method to your `map()` method and pass in an empty string for
|
||||
You should add `join("")` to the existing code.
|
||||
|
||||
```js
|
||||
assert.match(code, /<button\s+class\s*=\s*('|")playlist-song-delete\1\s*aria-label\s*=\s*('|")Delete\s*\$\{song\.title\}\2>\s*<svg\s{1}width="20"\s{1}height="20"\s{1}viewBox="0\s{1}0\s{1}16\s{1}16"\s{1}fill="none"\s{1}xmlns="http:\/\/www\.w3\.org\/2000\/svg">\s*<circle\s{1}cx="8"\s{1}cy="8"\s{1}r="8"\s{1}fill="#4d4d62"\/>\s*<path\s{1}fill-rule="evenodd"\s{1}clip-rule="evenodd"\s{1}d="M5\.32587\s{1}5\.18571C5\.7107\s{1}4\.90301\s{1}6\.28333\s{1}4\.94814\s{1}6\.60485\s{1}5\.28651L8\s{1}6\.75478L9\.39515\s{1}5\.28651C9\.71667\s{1}4\.94814\s{1}10\.2893\s{1}4\.90301\s{1}10\.6741\s{1}5\.18571C11\.059\s{1}5\.4684\s{1}11\.1103\s{1}5\.97188\s{1}10\.7888\s{1}6\.31026L9\.1832\s{1}7\.99999L10\.7888\s{1}9\.68974C11\.1103\s{1}10\.0281\s{1}11\.059\s{1}10\.5316\s{1}10\.6741\s{1}10\.8143C10\.2893\s{1}11\.097\s{1}9\.71667\s{1}11\.0519\s{1}9\.39515\s{1}10\.7135L8\s{1}9\.24521L6\.60485\s{1}10\.7135C6\.28333\s{1}11\.0519\s{1}5\.7107\s{1}11\.097\s{1}5\.32587\s{1}10\.8143C4\.94102\s{1}10\.5316\s{1}4\.88969\s{1}10\.0281\s{1}5\.21121\s{1}9\.68974L6\.8168\s{1}7\.99999L5\.21122\s{1}6\.31026C4\.8897\s{1}5\.97188\s{1}4\.94102\s{1}5\.4684\s{1}5\.32587\s{1}5\.18571Z"\s{1}fill="white"\/>\s*<\/svg>\s*<\/button>\s*<\/li>\s*`;?\s*\}\)\s*.join\(('|")\3\);?/)
|
||||
assert.match(code, /<button\s+class\s*=\s*('|")playlist-song-delete\1\s*aria-label\s*=\s*('|")Delete\s*\$\{song\.title\}\2>\s*<svg\s{1}width="20"\s{1}height="20"\s{1}viewBox="0\s{1}0\s{1}16\s{1}16"\s{1}fill="none"\s{1}xmlns="http:\/\/www\.w3\.org\/2000\/svg">\s*<circle\s{1}cx="8"\s{1}cy="8"\s{1}r="8"\s{1}fill="#4d4d62"\/>\s*<path\s{1}fill-rule="evenodd"\s{1}clip-rule="evenodd"\s{1}d="M5\.32587\s{1}5\.18571C5\.7107\s{1}4\.90301\s{1}6\.28333\s{1}4\.94814\s{1}6\.60485\s{1}5\.28651L8\s{1}6\.75478L9\.39515\s{1}5\.28651C9\.71667\s{1}4\.94814\s{1}10\.2893\s{1}4\.90301\s{1}10\.6741\s{1}5\.18571C11\.059\s{1}5\.4684\s{1}11\.1103\s{1}5\.97188\s{1}10\.7888\s{1}6\.31026L9\.1832\s{1}7\.99999L10\.7888\s{1}9\.68974C11\.1103\s{1}10\.0281\s{1}11\.059\s{1}10\.5316\s{1}10\.6741\s{1}10\.8143C10\.2893\s{1}11\.097\s{1}9\.71667\s{1}11\.0519\s{1}9\.39515\s{1}10\.7135L8\s{1}9\.24521L6\.60485\s{1}10\.7135C6\.28333\s{1}11\.0519\s{1}5\.7107\s{1}11\.097\s{1}5\.32587\s{1}10\.8143C4\.94102\s{1}10\.5316\s{1}4\.88969\s{1}10\.0281\s{1}5\.21121\s{1}9\.68974L6\.8168\s{1}7\.99999L5\.21122\s{1}6\.31026C4\.8897\s{1}5\.97188\s{1}4\.94102\s{1}5\.4684\s{1}5\.32587\s{1}5\.18571Z"\s{1}fill="white"\/>\s*<\/svg>\s*<\/button>\s*<\/li>\s*`;?\s*\}\)\s*\.join\(('|")\3\);?/)
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -22,7 +22,7 @@ assert.match(code, /if\s*\(userData\?\.currentSong\s*===\s*null\)\s*\{/)
|
||||
You should call the `playSong` function with `userData?.songs[0].id` inside your `if` block.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(userData\?\.currentSong\s*===\s*null\)\s*\{\s*playSong\(userData\?.songs\[0\]\.id\);?\s*\}/)
|
||||
assert.match(code, /if\s*\(userData\?\.currentSong\s*===\s*null\)\s*\{\s*playSong\(userData\?\.songs\[0\]\.id\);?\s*\}/)
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -16,20 +16,20 @@ This ensures that the currently playing song will continue to play when the play
|
||||
You should not modify the existing `if` statement and its content.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(userData\?\.currentSong\s*===\s*null\)\s*\{\s*playSong\(userData\?.songs\[0\]\.id\);?\s*\}/)
|
||||
assert.match(code, /if\s*\(userData\?\.currentSong\s*===\s*null\)\s*\{\s*playSong\(userData\?\.songs\[0\]\.id\);?\s*\}/)
|
||||
```
|
||||
|
||||
You should add an `else` block to your `if` statement.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(userData\?\.currentSong\s*===\s*null\)\s*\{\s*playSong\(userData\?.songs\[0\]\.id\);?\s*\}\s*else\s*\{/)
|
||||
assert.match(code, /if\s*\(userData\?\.currentSong\s*===\s*null\)\s*\{\s*playSong\(userData\?\.songs\[0\]\.id\);?\s*\}\s*else\s*\{/)
|
||||
```
|
||||
|
||||
You should call the `playSong` function with `userData?.currentSong.id` in the `else` block of your `if` statement.
|
||||
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(userData\?\.currentSong\s*===\s*null\)\s*\{\s*playSong\(userData\?.songs\[0\]\.id\);?\s*\}\s*else\s*\{\s*playSong\(userData\?\.currentSong\.id\);?\s*\}/)
|
||||
assert.match(code, /if\s*\(userData\?\.currentSong\s*===\s*null\)\s*\{\s*playSong\(userData\?\.songs\[0\]\.id\);?\s*\}\s*else\s*\{\s*playSong\(userData\?\.currentSong\.id\);?\s*\}/)
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -22,25 +22,25 @@ assert.match(code, /const\s+playPreviousSong\s*=\s*\(\)\s*=>\s*\{\s*/)
|
||||
You should have an `if` statement with the condition `userData?.currentSong === null` inside your `playPreviousSong` function.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+playPreviousSong\s*=\s*\(\)\s*=>\s*\{\s*if\s*\(userData\?.currentSong\s*===\s*null\)\s*\{?\s*/)
|
||||
assert.match(code, /const\s+playPreviousSong\s*=\s*\(\)\s*=>\s*\{\s*if\s*\(userData\?\.currentSong\s*===\s*null\)\s*\{?\s*/)
|
||||
```
|
||||
|
||||
You should have `return` inside the block of your `if` statement.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+playPreviousSong\s*=\s*\(\)\s*=>\s*\{\s*if\s*\(userData\?.currentSong\s*===\s*null\)\s*\{?\s*return;?\s*\}?/)
|
||||
assert.match(code, /const\s+playPreviousSong\s*=\s*\(\)\s*=>\s*\{\s*if\s*\(userData\?\.currentSong\s*===\s*null\)\s*\{?\s*return;?\s*\}?/)
|
||||
```
|
||||
|
||||
Your `if` statement should have an `else` block.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+playPreviousSong\s*=\s*\(\)\s*=>\s*\{\s*if\s*\(userData\?.currentSong\s*===\s*null\)\s*\{?\s*return;?\s*\}?\s*else\s*\{\s*/)
|
||||
assert.match(code, /const\s+playPreviousSong\s*=\s*\(\)\s*=>\s*\{\s*if\s*\(userData\?\.currentSong\s*===\s*null\)\s*\{?\s*return;?\s*\}?\s*else\s*\{\s*/)
|
||||
```
|
||||
|
||||
You should call `getCurrentSongIndex` and assign it to `currentSongIndex` inside the `else` block of your `if` statement.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+playPreviousSong\s*=\s*\(\)\s*=>\s*\{\s*if\s*\(userData\?.currentSong\s*===\s*null\)\s*\{?\s*return;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\);?\s*/)
|
||||
assert.match(code, /const\s+playPreviousSong\s*=\s*\(\)\s*=>\s*\{\s*if\s*\(userData\?\.currentSong\s*===\s*null\)\s*\{?\s*return;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\);?\s*/)
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -14,19 +14,19 @@ To get the previous song, subtract `1` from the `currentSongIndex` of `userData?
|
||||
You should not modify the existing `if` statement and its content.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(userData\?.currentSong\s*===\s*null\)\s*\{?\s*return;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\);?\s*/)
|
||||
assert.match(code, /if\s*\(userData\?\.currentSong\s*===\s*null\)\s*\{?\s*return;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\);?\s*/)
|
||||
```
|
||||
|
||||
You should assign `userData?.songs[currentSongIndex - 1]` to a `previousSong` constant.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(userData\?.currentSong\s*===\s*null\)\s*\{?\s*return;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\);?\s*const\s+previousSong\s*=\s*userData\?\.songs\[currentSongIndex\s*-\s*1\];?\s*/)
|
||||
assert.match(code, /if\s*\(userData\?\.currentSong\s*===\s*null\)\s*\{?\s*return;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\);?\s*const\s+previousSong\s*=\s*userData\?\.songs\[currentSongIndex\s*-\s*1\];?\s*/)
|
||||
```
|
||||
|
||||
You should call the `playSong` function with `previousSong.id`.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(userData\?.currentSong\s*===\s*null\)\s*\{?\s*return;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\);?\s*const\s+previousSong\s*=\s*userData\?\.songs\[currentSongIndex\s*-\s*1\];?\s*playSong\(previousSong\.id\);?\s*\}/)
|
||||
assert.match(code, /if\s*\(userData\?\.currentSong\s*===\s*null\)\s*\{?\s*return;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\);?\s*const\s+previousSong\s*=\s*userData\?\.songs\[currentSongIndex\s*-\s*1\];?\s*playSong\(previousSong\.id\);?\s*\}/)
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -27,25 +27,25 @@ Then, use a `ternary` operator to check if `currentArtist` is truthy. If so, imp
|
||||
You should chain the `textContent` property to `playingSong`.
|
||||
|
||||
```js
|
||||
assert.match(code, /playingSong.textContent\s*/)
|
||||
assert.match(code, /playingSong\.textContent\s*/)
|
||||
```
|
||||
|
||||
You should use the `ternary` operator to set the `textContent` property of `playingSong` to `currentTitle` or `""`.
|
||||
|
||||
```js
|
||||
assert.match(code, /playingSong.textContent\s*=\s*currentTitle\s*\?\s*currentTitle\s*:\s*('|")\1;?/)
|
||||
assert.match(code, /playingSong\.textContent\s*=\s*currentTitle\s*\?\s*currentTitle\s*:\s*('|")\1;?/)
|
||||
```
|
||||
|
||||
You should chain the `textContent` property to `songArtist`.
|
||||
|
||||
```js
|
||||
assert.match(code, /songArtist.textContent\s*/)
|
||||
assert.match(code, /songArtist\.textContent\s*/)
|
||||
```
|
||||
|
||||
You should use the `ternary` operator to set the `textContent` property of `songArtist` to `currentArtist` or `""`.
|
||||
|
||||
```js
|
||||
assert.match(code, /songArtist.textContent\s*=\s*currentArtist\s*\?\s*currentArtist\s*:\s*('|")\1;?/)
|
||||
assert.match(code, /songArtist\.textContent\s*=\s*currentArtist\s*\?\s*currentArtist\s*:\s*('|")\1;?/)
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -23,13 +23,13 @@ Pass in a callback function to the `map()` method. The callback function should
|
||||
The callback function of your `map()` method should use arrow function syntax.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+songsHTML\s*=\s*array.map\(\(?.*\)?\s*=>\s*\{\s*\}\)/)
|
||||
assert.match(code, /const\s+songsHTML\s*=\s*array\.map\(\(?.*\)?\s*=>\s*\{\s*\}\)/)
|
||||
```
|
||||
|
||||
Your `map()` method should have a `song` parameter in it's callback function.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+songsHTML\s*=\s*array.map\(\(?song\)?/)
|
||||
assert.match(code, /const\s+songsHTML\s*=\s*array\.map\(\(?song\)?/)
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -22,13 +22,13 @@ assert.notMatch(code, /\.then\(\(?res\)?\s*=>\s*console\.log\(res\)\)/)
|
||||
You should implicitly return `res.json()` in your `.then()`.
|
||||
|
||||
```js
|
||||
assert.match(code, /\.then\(\(?res\)?\s*=>\s*res.json\(\)\)/)
|
||||
assert.match(code, /\.then\(\(?res\)?\s*=>\s*res\.json\(\)\)/)
|
||||
```
|
||||
|
||||
You should not have a semi-colon after your `.then()`.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /\.then\(\(?res\)?\s*=>\s*res.json\(\)\);/)
|
||||
assert.notMatch(code, /\.then\(\(?res\)?\s*=>\s*res\.json\(\)\);/)
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -23,43 +23,43 @@ assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/
|
||||
Your first `.then()` should not have a semi-colon.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res.json\(\s*\)\s*\);/)
|
||||
assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\);/)
|
||||
```
|
||||
|
||||
You should chain another `.then()` to the existing `.then()`.
|
||||
|
||||
```js
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res.json\(\s*\)\s*\)\s*\.then\(/)
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(/)
|
||||
```
|
||||
|
||||
You should add a `data` parameter to your second `.then()` method.
|
||||
|
||||
```js
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)/)
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)/)
|
||||
```
|
||||
|
||||
Your second `.then()` method should use arrow function syntax.
|
||||
|
||||
```js
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*/)
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*/)
|
||||
```
|
||||
|
||||
Your second `.then()` method should have curly braces.
|
||||
|
||||
```js
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*/)
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*/)
|
||||
```
|
||||
|
||||
Your second `.then()` method should log `data` to the console.
|
||||
|
||||
```js
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\s*\}\s*\)/)
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\s*\}\s*\)/)
|
||||
```
|
||||
|
||||
Your second `.then()` should not not have semi-colon after it.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s(\(\s*res\s*\)|res)\s*=>\s*res.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\s*\}\s*\)\s*;/)
|
||||
assert.notMatch(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\s*\}\s*\)\s*;/)
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -24,61 +24,61 @@ assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/
|
||||
You should chain another `.then()` to the existing `.then()`.
|
||||
|
||||
```js
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res.json\(\s*\)\s*\)\s*\.then\(/)
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(/)
|
||||
```
|
||||
|
||||
You should add a `data` parameter to your second `.then()` method.
|
||||
|
||||
```js
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)/)
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)/)
|
||||
```
|
||||
|
||||
Your second `.then()` method should use arrow function syntax.
|
||||
|
||||
```js
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*/)
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*/)
|
||||
```
|
||||
|
||||
Your second `.then()` method should have curly braces.
|
||||
|
||||
```js
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*/)
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*/)
|
||||
```
|
||||
|
||||
Your second `.then()` method should log `data` to the console.
|
||||
|
||||
```js
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\)/)
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\)/)
|
||||
```
|
||||
|
||||
Your second `.then()` should not have a semicolon.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\);/)
|
||||
assert.notMatch(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\);/)
|
||||
```
|
||||
|
||||
You should chain the `.catch()` method to the second `.then()` you already have.
|
||||
|
||||
```js
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(/)
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(/)
|
||||
```
|
||||
|
||||
You should add an `err` parameter to your `.catch()` method.
|
||||
|
||||
```js
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res.json\(\s*\)\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/)
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/)
|
||||
```
|
||||
|
||||
Your `.catch()` method should have an arrow function syntax.
|
||||
|
||||
```js
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res.json\(\s*\)\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/)
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/)
|
||||
```
|
||||
|
||||
Your `.catch()` method should use `console.error()` to log `err` to the console with the text `` `There was an error: ${err}` ``. Don't forget to use backticks.
|
||||
|
||||
```js
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\);?\n?(\s*)?\}?\)\s*;?/)
|
||||
assert.match(code, /fetch\(('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\);?\n?(\s*)?\}?\)\s*;?/)
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -34,19 +34,19 @@ assert.match(code, /displayAuthors\(/)
|
||||
You should call your `displayAuthors` function and pass in an argument of `authorDataArr.slice()`.
|
||||
|
||||
```js
|
||||
assert.match(code, /displayAuthors\(authorDataArr.slice\(/)
|
||||
assert.match(code, /displayAuthors\(authorDataArr\.slice\(/)
|
||||
```
|
||||
|
||||
The first parameter of your `slice()` method should be `startingIndex`.
|
||||
|
||||
```js
|
||||
assert.match(code, /displayAuthors\(authorDataArr.slice\(startingIndex/)
|
||||
assert.match(code, /displayAuthors\(authorDataArr\.slice\(startingIndex/)
|
||||
```
|
||||
|
||||
The second parameter of your `slice()` method should be `endingIndex`.
|
||||
|
||||
```js
|
||||
assert.match(code, /displayAuthors\(authorDataArr.slice\(startingIndex\,\s*endingIndex\)\);?/)
|
||||
assert.match(code, /displayAuthors\(authorDataArr\.slice\(startingIndex\,\s*endingIndex\)\);?/)
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -18,19 +18,19 @@ With that, your author page is complete!
|
||||
You should access the `style` property of `loadMoreBtn` with a dot notation.
|
||||
|
||||
```js
|
||||
assert.match(code, /loadMoreBtn.style/)
|
||||
assert.match(code, /loadMoreBtn\.style/)
|
||||
```
|
||||
|
||||
You should access `cursor` from the `style` property with dot notation.
|
||||
|
||||
```js
|
||||
assert.match(code, /loadMoreBtn.style.cursor/)
|
||||
assert.match(code, /loadMoreBtn\.style\.cursor/)
|
||||
```
|
||||
|
||||
You should set the value of the `cursor` property to `not-allowed`.
|
||||
|
||||
```js
|
||||
assert.match(code, /loadMoreBtn.style.cursor\s*=\s*('|"|`)not\-allowed\1;?/)
|
||||
assert.match(code, /loadMoreBtn\.style\.cursor\s*=\s*('|"|`)not\-allowed\1;?/)
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -14,13 +14,13 @@ Give your `label` element a `for` attribute with the value `X-#-name`, where `X`
|
||||
Your `label` element should have a `for` attribute set to `${entryDropdown.value}-${entryNumber}-name`.
|
||||
|
||||
```js
|
||||
assert.match(code, /HTMLString\s*=\s*`\n\s*<label\s+for\s*=\s*"\$\{entryDropdown.value\}-\$\{entryNumber\}-name"\s*>/)
|
||||
assert.match(code, /HTMLString\s*=\s*`\n\s*<label\s+for\s*=\s*"\$\{entryDropdown\.value\}-\$\{entryNumber\}-name"\s*>/)
|
||||
```
|
||||
|
||||
Your `label` element should have the same text as before.
|
||||
|
||||
```js
|
||||
assert.match(code, /HTMLString\s*=\s*`\n\s*<label\s+for\s*=\s*"\$\{entryDropdown.value\}-\$\{entryNumber\}-name"\s*>Entry\s\$\{entryNumber\}\sName<\/label>/);
|
||||
assert.match(code, /HTMLString\s*=\s*`\n\s*<label\s+for\s*=\s*"\$\{entryDropdown\.value\}-\$\{entryNumber\}-name"\s*>Entry\s\$\{entryNumber\}\sName<\/label>/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -14,13 +14,13 @@ After your `label` element, and on a new line in your template string, create an
|
||||
You should not modify your `label` element.
|
||||
|
||||
```js
|
||||
assert.match(code, /HTMLString\s*=\s*`\n\s*<label\s+for\s*=\s*"\$\{entryDropdown.value\}-\$\{entryNumber\}-name"\s*>Entry\s\$\{entryNumber\}\sName<\/label>/);
|
||||
assert.match(code, /HTMLString\s*=\s*`\n\s*<label\s+for\s*=\s*"\$\{entryDropdown\.value\}-\$\{entryNumber\}-name"\s*>Entry\s\$\{entryNumber\}\sName<\/label>/);
|
||||
```
|
||||
|
||||
You should add an `input` element on a new line.
|
||||
|
||||
```js
|
||||
assert.match(code, /HTMLString\s*=\s*`\n\s*<label\s+for\s*=\s*"\$\{entryDropdown.value\}-\$\{entryNumber\}-name"\s*>Entry\s\$\{entryNumber\}\sName<\/label>\n\s*<input/);
|
||||
assert.match(code, /HTMLString\s*=\s*`\n\s*<label\s+for\s*=\s*"\$\{entryDropdown\.value\}-\$\{entryNumber\}-name"\s*>Entry\s\$\{entryNumber\}\sName<\/label>\n\s*<input/);
|
||||
```
|
||||
|
||||
Your `input` element should have a `type` attribute set to `text`.
|
||||
|
||||
@@ -26,7 +26,7 @@ assert.match(code, /container\.appendChild\(\s*label\s*\)/);
|
||||
You should append `label` after setting the attributes.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+label\s*=\s*document.createElement\(\s*('|"|`)div\1\s*\);?\s*label\.className\s*=\s*('|"|`)label\2;?\s*label\.textContent\s*=\s*name;?\s*container\.appendChild\(\s*label\s*\)/);
|
||||
assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\);?\s*label\.className\s*=\s*('|"|`)label\2;?\s*label\.textContent\s*=\s*name;?\s*container\.appendChild\(\s*label\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -28,7 +28,7 @@ assert.match(code, /const\s+range\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*Array\(
|
||||
You should pass `start` to the `.fill()` method.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+range\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*Array\(\s*end\s*-\s*start\s*\+\s*1\s*\).fill\(\s*start\s*\)/);
|
||||
assert.match(code, /const\s+range\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*Array\(\s*end\s*-\s*start\s*\+\s*1\s*\)\.fill\(\s*start\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -22,37 +22,37 @@ assert.match(code, /\.map\(/);
|
||||
You should chain the `.map()` method to your `.fill()` method.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+range\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*Array\(\s*end\s*-\s*start\s*\+\s*1\s*\).fill\(\s*start\s*\)\.map\(/);
|
||||
assert.match(code, /const\s+range\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*Array\(\s*end\s*-\s*start\s*\+\s*1\s*\)\.fill\(\s*start\s*\)\.map\(/);
|
||||
```
|
||||
|
||||
You should pass a callback function to `.map()` using arrow syntax.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+range\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*Array\(\s*end\s*-\s*start\s*\+\s*1\s*\).fill\(\s*start\s*\)\.map\(\s*\(.*\)\s*=>/);
|
||||
assert.match(code, /const\s+range\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*Array\(\s*end\s*-\s*start\s*\+\s*1\s*\)\.fill\(\s*start\s*\)\.map\(\s*\(.*\)\s*=>/);
|
||||
```
|
||||
|
||||
Your `.map()` callback should take `element` as the first parameter.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+range\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*Array\(\s*end\s*-\s*start\s*\+\s*1\s*\).fill\(\s*start\s*\)\.map\(\s*\(\s*element/);
|
||||
assert.match(code, /const\s+range\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*Array\(\s*end\s*-\s*start\s*\+\s*1\s*\)\.fill\(\s*start\s*\)\.map\(\s*\(\s*element/);
|
||||
```
|
||||
|
||||
Your `.map()` callback should take `index` as the second parameter.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+range\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*Array\(\s*end\s*-\s*start\s*\+\s*1\s*\).fill\(\s*start\s*\)\.map\(\s*\(\s*element\s*,\s*index\s*\)\s*=>/);
|
||||
assert.match(code, /const\s+range\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*Array\(\s*end\s*-\s*start\s*\+\s*1\s*\)\.fill\(\s*start\s*\)\.map\(\s*\(\s*element\s*,\s*index\s*\)\s*=>/);
|
||||
```
|
||||
|
||||
Your `.map()` callback should use an implicit return.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /const\s+range\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*Array\(\s*end\s*-\s*start\s*\+\s*1\s*\).fill\(\s*start\s*\)\.map\(\s*\(\s*element\s*,\s*index\s*\)\s*=>\s*\{/);
|
||||
assert.notMatch(code, /const\s+range\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*Array\(\s*end\s*-\s*start\s*\+\s*1\s*\)\.fill\(\s*start\s*\)\.map\(\s*\(\s*element\s*,\s*index\s*\)\s*=>\s*\{/);
|
||||
```
|
||||
|
||||
Your `.map()` callback should implicitly return the sum of `element` and `index`.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+range\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*Array\(\s*end\s*-\s*start\s*\+\s*1\s*\).fill\(\s*start\s*\)\.map\(\s*\(\s*element\s*,\s*index\s*\)\s*=>\s*(element\s*\+\s*index|index\s*\+\s*element)/);
|
||||
assert.match(code, /const\s+range\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*Array\(\s*end\s*-\s*start\s*\+\s*1\s*\)\.fill\(\s*start\s*\)\.map\(\s*\(\s*element\s*,\s*index\s*\)\s*=>\s*(element\s*\+\s*index|index\s*\+\s*element)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -28,31 +28,31 @@ assert.match(code, /const\s+charRange\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*ran
|
||||
You should use arrow syntax for the `.map()` callback.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+charRange\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*range\(\s*start\.charCodeAt\(\s*0\s*\)\s*,\s*end\.charCodeAt\(\s*0\s*\)\s*\).map\(\s*(\(.*\)|[^\s()]+)\s*=>/);
|
||||
assert.match(code, /const\s+charRange\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*range\(\s*start\.charCodeAt\(\s*0\s*\)\s*,\s*end\.charCodeAt\(\s*0\s*\)\s*\)\.map\(\s*(\(.*\)|[^\s()]+)\s*=>/);
|
||||
```
|
||||
|
||||
Your `.map()` callback should take a `code` parameter.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+charRange\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*range\(\s*start\.charCodeAt\(\s*0\s*\)\s*,\s*end\.charCodeAt\(\s*0\s*\)\s*\).map\(\s*(\(\s*code\s*\)|code)\s*=>/);
|
||||
assert.match(code, /const\s+charRange\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*range\(\s*start\.charCodeAt\(\s*0\s*\)\s*,\s*end\.charCodeAt\(\s*0\s*\)\s*\)\.map\(\s*(\(\s*code\s*\)|code)\s*=>/);
|
||||
```
|
||||
|
||||
Your `.map()` callback should use an implicit return.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /const\s+charRange\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*range\(\s*start\.charCodeAt\(\s*0\s*\)\s*,\s*end\.charCodeAt\(\s*0\s*\)\s*\).map\(\s*(\(\s*code\s*\)|code)\s*=>\s*\{/);
|
||||
assert.notMatch(code, /const\s+charRange\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*range\(\s*start\.charCodeAt\(\s*0\s*\)\s*,\s*end\.charCodeAt\(\s*0\s*\)\s*\)\.map\(\s*(\(\s*code\s*\)|code)\s*=>\s*\{/);
|
||||
```
|
||||
|
||||
Your `.map()` callback should return the result of calling `String.fromCharCode()`.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+charRange\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*range\(\s*start\.charCodeAt\(\s*0\s*\)\s*,\s*end\.charCodeAt\(\s*0\s*\)\s*\).map\(\s*(\(\s*code\s*\)|code)\s*=>\s*String\.fromCharCode\(/);
|
||||
assert.match(code, /const\s+charRange\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*range\(\s*start\.charCodeAt\(\s*0\s*\)\s*,\s*end\.charCodeAt\(\s*0\s*\)\s*\)\.map\(\s*(\(\s*code\s*\)|code)\s*=>\s*String\.fromCharCode\(/);
|
||||
```
|
||||
|
||||
You should pass the variable `code` to `String.fromCharCode()`.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+charRange\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*range\(\s*start\.charCodeAt\(\s*0\s*\)\s*,\s*end\.charCodeAt\(\s*0\s*\)\s*\).map\(\s*(\(\s*code\s*\)|code)\s*=>\s*String\.fromCharCode\(\s*code\s*\)/);
|
||||
assert.match(code, /const\s+charRange\s*=\s*\(\s*start\s*,\s*end\s*\)\s*=>\s*range\(\s*start\.charCodeAt\(\s*0\s*\)\s*,\s*end\.charCodeAt\(\s*0\s*\)\s*\)\.map\(\s*(\(\s*code\s*\)|code)\s*=>\s*String\.fromCharCode\(\s*code\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -41,7 +41,7 @@ assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\(?item\)?/)
|
||||
Your arrow function callback should check if `item.id === currentTask.id`.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\(?item\)?\s*=>\s*item.id\s*===\s*currentTask.id\s*\);?/)
|
||||
assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\(?item\)?\s*=>\s*item\.id\s*===\s*currentTask\.id\s*\);?/)
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -16,7 +16,7 @@ Set `taskData` to the retrieval of `data` from local storage **or** an empty arr
|
||||
You should set the `taskData` variable to `JSON.parse(localStorage.getItem("data")) || [];`.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+taskData\s*=\s*JSON.parse\(localStorage\.getItem\(('|")data\1\)\)\s*\|\|\s*\[\];?/)
|
||||
assert.match(code, /const\s+taskData\s*=\s*JSON\.parse\(localStorage\.getItem\(('|")data\1\)\)\s*\|\|\s*\[\];?/)
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -15,7 +15,7 @@ Use object destructuring to access the `coachName` value.
|
||||
|
||||
```js
|
||||
|
||||
assert.match(code, /const\s*{\s*coachName\s*}\s*=\s*myFavoriteFootballTeam.headCoach\s*/)
|
||||
assert.match(code, /const\s*{\s*coachName\s*}\s*=\s*myFavoriteFootballTeam\.headCoach\s*/)
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ You should assign the `sport` variable to `typeOfSport.textContent`.
|
||||
|
||||
```js
|
||||
|
||||
assert.match(code, /typeOfSport.textContent\s*=\s*sport\s*/)
|
||||
assert.match(code, /typeOfSport\.textContent\s*=\s*sport\s*/)
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ You should assign the `team` variable to `teamName.textContent`.
|
||||
|
||||
```js
|
||||
|
||||
assert.match(code, /teamName.textContent\s*=\s*team\s*/)
|
||||
assert.match(code, /teamName\.textContent\s*=\s*team\s*/)
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ You should assign the `year` variable to `worldCupYear.textContent`.
|
||||
|
||||
```js
|
||||
|
||||
assert.match(code, /worldCupYear.textContent\s*=\s*year\s*/)
|
||||
assert.match(code, /worldCupYear\.textContent\s*=\s*year\s*/)
|
||||
|
||||
```
|
||||
|
||||
@@ -27,7 +27,7 @@ You should assign the `coachName` variable to `headCoach.textContent`.
|
||||
|
||||
```js
|
||||
|
||||
assert.match(code, /headCoach.textContent\s*=\s*coachName\s*/)
|
||||
assert.match(code, /headCoach\.textContent\s*=\s*coachName\s*/)
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ Open the console, and make a selection from the teammates dropdown menu. You sho
|
||||
You should add a `console.log` with the value of `e.target.value`.
|
||||
|
||||
```js
|
||||
assert.match(code, /console.log\s*\(e.target.value\)\s*/)
|
||||
assert.match(code, /console\.log\s*\(e\.target\.value\)\s*/)
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -18,7 +18,7 @@ Inside the callback function, access the `innerHTML` property of the `playerCard
|
||||
You should not have the `console.log` statement in your code.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /\s*console.log\(e.target.value\)/);
|
||||
assert.notMatch(code, /\s*console\.log\(e\.target\.value\)/);
|
||||
```
|
||||
|
||||
You should access the `innerHTML` property of the `playerCards` element.
|
||||
@@ -30,7 +30,7 @@ assert.match(code, /playerCards\.innerHTML\s*=/);
|
||||
You should set the `innerHTML` property to an empty string.
|
||||
|
||||
```js
|
||||
assert.match(code, /\s*playerCards.innerHTML\s*=\s*('|"|`)\1/)
|
||||
assert.match(code, /\s*playerCards\.innerHTML\s*=\s*('|"|`)\1/)
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -26,13 +26,13 @@ assert.notMatch(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*{\s*.*conso
|
||||
Your `if` statement should check if `e.key` is equal to the string `Enter`.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(\s*(?:e\s*\.\s*key\s*===?\s*('|"|`)Enter\1|('|"|`)Enter\2\s*===?\s*e\s*.key)\s*\)\s*\{/);
|
||||
assert.match(code, /if\s*\(\s*(?:e\s*\.\s*key\s*===?\s*('|"|`)Enter\1|('|"|`)Enter\2\s*===?\s*e\s*\.key)\s*\)\s*\{/);
|
||||
```
|
||||
|
||||
The body of your `if` statement should be empty.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(\s*(?:e\s*\.\s*key\s*===?\s*('|"|`)Enter\1|('|"|`)Enter\2\s*===?\s*e\s*.key)\s*\)\s*\{\s*\}/);
|
||||
assert.match(code, /if\s*\(\s*(?:e\s*\.\s*key\s*===?\s*('|"|`)Enter\1|('|"|`)Enter\2\s*===?\s*e\s*\.key)\s*\)\s*\{\s*\}/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -16,7 +16,7 @@ Also, make sure to remove your `console.log(formattedDate);` line.
|
||||
You should use the `textContent` property to set the text content of `currentDateParagraph` to the value of the constant `formattedDate`.
|
||||
|
||||
```js
|
||||
assert(code.match(/currentDateParagraph.textContent\s*=\s*formattedDate/g));
|
||||
assert(code.match(/currentDateParagraph\.textContent\s*=\s*formattedDate/g));
|
||||
```
|
||||
|
||||
You should not have a `console.log(formattedDate);` line in your code.
|
||||
|
||||
@@ -22,13 +22,13 @@ Chain the `addEventListener` method to `dateOptionsSelectElement` where the firs
|
||||
You should use the `addEventListener` method to add a `change` event listener to `dateOptionsSelectElement`.
|
||||
|
||||
```js
|
||||
assert(code.match(/dateOptionsSelectElement.addEventListener\s*\(\s*('|")change\1/g));
|
||||
assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(\s*('|")change\1/g));
|
||||
```
|
||||
|
||||
You should add an empty arrow function as the second argument to the `addEventListener` method.
|
||||
|
||||
```js
|
||||
assert(code.match(/dateOptionsSelectElement.addEventListener\s*\(\s*('|")change\1\s*,\s*\(\s*\)\s*=>\s*{\s*}/g));
|
||||
assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(\s*('|")change\1\s*,\s*\(\s*\)\s*=>\s*{\s*}/g));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -34,7 +34,7 @@ Create a `switch` statement and use `dateOptionsSelectElement.value` as the expr
|
||||
You should use a `switch` statement where `dateOptionsSelectElement.value` is the expression.
|
||||
|
||||
```js
|
||||
assert(code.match(/switch\s*\(\s*dateOptionsSelectElement.value\s*\)/g));
|
||||
assert(code.match(/switch\s*\(\s*dateOptionsSelectElement\.value\s*\)/g));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -26,7 +26,7 @@ Add a `case` where the value is `yyyy-mm-dd`. Inside the `case`, set the text co
|
||||
You should add a `case` where the condition is `yyyy-mm-dd`. Then set the `textContent` property of `currentDateParagraph` equal to `formattedDate`.
|
||||
|
||||
```js
|
||||
assert(code.match(/case\s*('|")yyyy-mm-dd\1\s*:\s*currentDateParagraph.textContent\s*=\s*formattedDate/g));
|
||||
assert(code.match(/case\s*('|")yyyy-mm-dd\1\s*:\s*currentDateParagraph\.textContent\s*=\s*formattedDate/g));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -16,13 +16,13 @@ Also, make sure to include a `break` statement to terminate the `switch` stateme
|
||||
You should add a `case` where the condition is `mm-dd-yyyy-h-mm`, then set the `textContent` property of `currentDateParagraph` equal to empty template literals.
|
||||
|
||||
```js
|
||||
assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph.textContent\s*=\s*``/g));
|
||||
assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph\.textContent\s*=\s*``/g));
|
||||
```
|
||||
|
||||
You should include a `break` statement within the `case` after your logic.
|
||||
|
||||
```js
|
||||
assert(code.match(/currentDateParagraph.textContent\s*=\s*``\;?\n+\s*break/g));
|
||||
assert(code.match(/currentDateParagraph\.textContent\s*=\s*``\;?\n+\s*break/g));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -34,7 +34,7 @@ And with that, your date formatter is complete! You can now format the current d
|
||||
You should use the `default` case to set the `textContent` property of `currentDateParagraph` to the value of `formattedDate`.
|
||||
|
||||
```js
|
||||
assert(code.match(/default\s*:\s*currentDateParagraph.textContent\s*=\s*formattedDate/g));
|
||||
assert(code.match(/default\s*:\s*currentDateParagraph\.textContent\s*=\s*formattedDate/g));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
Reference in New Issue
Block a user