Skip to content

Commit 12c2875

Browse files
a2937majestic-owl448naomi-lgbt
authored
chore(curriculum): update step 12 and 13 music player tests (freeCodeCamp#57361)
Co-authored-by: Ilenia <[email protected]> Co-authored-by: Naomi <[email protected]>
1 parent 19b54ff commit 12c2875

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/660ae8ad1475698da3c3c37d.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,45 @@ Your `printGreeting` function call should be below the `printGreeting` function
2929
assert.isBelow(code.indexOf("const printGreeting = () => {"), code.indexOf("printGreeting()"));
3030
```
3131

32+
Your `printGreeting` function call should output `Hello there!` to the console.
33+
34+
```js
35+
assert.strictEqual(logOutput, "Hello there!");
36+
```
37+
3238
# --seed--
3339

40+
## --before-user-code--
41+
42+
```js
43+
let logOutput = "";
44+
const originalConsole = console;
45+
function capture() {
46+
const nativeLog = console.log;
47+
console.log = function (message) {
48+
logOutput = message;
49+
if(nativeLog.apply) {
50+
nativeLog.apply(originalConsole, arguments);
51+
} else {
52+
const nativeMsg = Array.prototype.slice.apply(arguments).join(' ');
53+
nativeLog(nativeMsg);
54+
}
55+
};
56+
}
57+
58+
function uncapture() {
59+
console.log = originalConsole.log;
60+
}
61+
62+
capture();
63+
```
64+
65+
## --after-user-code--
66+
67+
```js
68+
uncapture();
69+
```
70+
3471
## --seed-contents--
3572

3673
```html

curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/660aea8782242e8f4bcc42d8.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,47 @@ const functionDefinition = code.indexOf("printMessage =");
7979
assert.isBelow(functionDefinition, functionCall);
8080
```
8181

82+
Your `printMessage` function call should output `freeCodeCamp is awesome!` to the console.
83+
84+
```js
85+
assert.strictEqual(logOutput, "freeCodeCamp is awesome!");
86+
```
87+
8288
# --seed--
8389

90+
91+
## --before-user-code--
92+
93+
```js
94+
let logOutput = "";
95+
const originalConsole = console;
96+
function capture() {
97+
const nativeLog = console.log;
98+
console.log = function (message) {
99+
logOutput = message;
100+
if(nativeLog.apply) {
101+
nativeLog.apply(originalConsole, arguments);
102+
} else {
103+
const nativeMsg = Array.prototype.slice.apply(arguments).join(' ');
104+
nativeLog(nativeMsg);
105+
}
106+
};
107+
}
108+
109+
function uncapture() {
110+
console.log = originalConsole.log;
111+
}
112+
113+
capture();
114+
```
115+
116+
## --after-user-code--
117+
118+
```js
119+
uncapture();
120+
```
121+
122+
84123
## --seed-contents--
85124

86125
```html

0 commit comments

Comments
 (0)