refactor(curriculum): remove after-user-code javascript 22 (#60338)

This commit is contained in:
Anna
2025-05-15 11:29:19 -04:00
committed by GitHub
parent 4c6faf9e6d
commit c37af5001b
5 changed files with 54 additions and 114 deletions

View File

@@ -51,6 +51,35 @@ Your application should show different messages depending on the price of the it
Fulfill the user stories and pass all the tests below to complete this project. Give it your own personal style. Happy Coding!
# --before-all--
```js
const _money = [
['ONE HUNDRED', 10000],
['TWENTY', 2000],
['TEN', 1000],
['FIVE', 500],
['ONE', 100],
['QUARTER', 25],
['DIME', 10],
['NICKEL', 5]
];
const _denomRegexes = [
/PENNY/,
/NICKEL/,
/DIME/,
/QUARTER/,
/ONE [^H]/,
/FIVE/,
/TEN/,
/TWENTY/,
/ONE HUNDRED/
];
function _randomNumber(max) {
return Math.floor(Math.random() * (max + 1));
}
```
# --hints--
You should have the HTML file link to the JavaScript file.
@@ -584,35 +613,6 @@ assert.isTrue(!notExpected.some(regex => result.match(new RegExp(regex, 'i'))));
# --seed--
## --after-user-code--
```js
const _money = [
['ONE HUNDRED', 10000],
['TWENTY', 2000],
['TEN', 1000],
['FIVE', 500],
['ONE', 100],
['QUARTER', 25],
['DIME', 10],
['NICKEL', 5]
];
const _denomRegexes = [
/PENNY/,
/NICKEL/,
/DIME/,
/QUARTER/,
/ONE [^H]/,
/FIVE/,
/TEN/,
/TWENTY/,
/ONE HUNDRED/
];
function _randomNumber(max) {
return Math.floor(Math.random() * (max + 1));
}
```
## --seed-contents--
```html

View File

@@ -13,6 +13,15 @@ Start by adding a `return` followed by a set of template literals. Inside the te
Inside the `img` tag, add a `src` attribute with the value of `${userAvatarUrl}`. For the `alt` attribute, add a value of `${user.name}`.
# --before-all--
```js
function getReturnCode(code) {
const returnAndRest = code.split(/:\s*avatar\s*;?/)?.[1];
return returnAndRest?.split(/\}\s*\}\s*\)\s*;?\s*\}\s*;?/)?.[0];
}
```
# --hints--
You should return a template literal.
@@ -59,15 +68,6 @@ assert.match(getReturnCode(code), altValue);
# --seed--
## --after-user-code--
```js
function getReturnCode(code) {
const returnAndRest = code.split(/:\s*avatar\s*;?/)?.[1];
return returnAndRest?.split(/\}\s*\}\s*\)\s*;?\s*\}\s*;?/)?.[0];
}
```
## --seed-contents--
```html

View File

@@ -32,42 +32,13 @@ assert.isBelow(code.indexOf("const printGreeting = () => {"), code.indexOf("prin
Your `printGreeting` function call should output `Hello there!` to the console.
```js
assert.strictEqual(logOutput, "Hello there!");
const spy = __helpers.spyOn(console, "log");
printGreeting();
assert.sameDeepOrderedMembers(spy.calls, [["Hello there!"]]);
```
# --seed--
## --before-user-code--
```js
let logOutput = "";
const originalConsole = console;
function capture() {
const nativeLog = console.log;
console.log = function (message) {
logOutput = message;
if(nativeLog.apply) {
nativeLog.apply(originalConsole, arguments);
} else {
const nativeMsg = Array.prototype.slice.apply(arguments).join(' ');
nativeLog(nativeMsg);
}
};
}
function uncapture() {
console.log = originalConsole.log;
}
capture();
```
## --after-user-code--
```js
uncapture();
```
## --seed-contents--
```html

View File

@@ -82,44 +82,13 @@ assert.isBelow(functionDefinition, functionCall);
Your `printMessage` function call should output `freeCodeCamp is awesome!` to the console.
```js
assert.strictEqual(logOutput, "freeCodeCamp is awesome!");
const spy = __helpers.spyOn(console, "log");
printGreeting();
assert.sameDeepOrderedMembers(spy.calls, [["Hello there!"]]);
```
# --seed--
## --before-user-code--
```js
let logOutput = "";
const originalConsole = console;
function capture() {
const nativeLog = console.log;
console.log = function (message) {
logOutput = message;
if(nativeLog.apply) {
nativeLog.apply(originalConsole, arguments);
} else {
const nativeMsg = Array.prototype.slice.apply(arguments).join(' ');
nativeLog(nativeMsg);
}
};
}
function uncapture() {
console.log = originalConsole.log;
}
capture();
```
## --after-user-code--
```js
uncapture();
```
## --seed-contents--
```html

View File

@@ -11,6 +11,16 @@ When the user clicks on the `Show rules` button, the rules for the game should d
Use an event listener to invert the value of the `isModalShowing` variable, toggle the visibility of the `rulesContainer`, and change the text of the `rulesBtn` to `Show rules` or `Hide rules`.
# --before-all--
```js
function resetState() {
isModalShowing = false;
rulesBtn.textContent = 'Show rules';
rulesContainer.style.display = 'none';
}
```
# --hints--
Your `rulesContainer` should not be visible initially.
@@ -75,16 +85,6 @@ resetState();
# --seed--
## --after-user-code--
```js
function resetState() {
isModalShowing = false;
rulesBtn.textContent = 'Show rules';
rulesContainer.style.display = 'none';
}
```
## --seed-contents--
```html