Skip to content

Commit 214f506

Browse files
gikfSembauke
andauthored
fix(curriculum): tests passing with seed code in Music player (freeCodeCamp#55586)
Co-authored-by: Sem Bauke <[email protected]>
1 parent 6a24f8a commit 214f506

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*{\s*[\s\S]*?\}\s*;?/);
3030
You should use the `sort()` method on `userData?.songs`.
3131

3232
```js
33-
assert.match(code, /userData\?\.songs\.sort\(/)
33+
assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*{\s*userData\?\.songs\.sort\(/);
3434
```
3535

3636
Your `sort()` method should have a callback function that uses arrow syntax.
3737

3838
```js
39-
assert.match(code, /userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*/)
39+
assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*{\s*userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*/);
4040
```
4141

4242
The callback of your `sort()` method should return `Math.random() - 0.5`.
4343

4444
```js
45-
assert.match(code, /userData\?\.songs\.sort\s*\(\s*\(\s*\)\s*=>(\s*{\s*return\s+Math\.random\(\s*\)\s*-\s*0\.5\s*;?\s*}\s*)|(\s*Math\.random\(\s*\)\s*-\s*0\.5\s*)\s*\)\s*;?/);
45+
assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*{\s*userData\?\.songs\.sort\s*\(\s*\(\s*\)\s*=>(\s*{\s*return\s+Math\.random\(\s*\)\s*-\s*0\.5\s*;?\s*}\s*)|(\s*Math\.random\(\s*\)\s*-\s*0\.5\s*)\s*\)\s*;?/);
4646
```
4747

4848
# --seed--

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ Inside your callback function, add another `if` statement to check if `a.title`
3333

3434
# --hints--
3535

36-
You should have an `if` statement inside your callback function.
36+
You should have a second `if` statement inside your callback function.
3737

3838
```js
39-
assert.match(code, /if\s*\(/);
39+
const callback = code.split(/const\s+sortSongs\s*=\s*\(\s*\)\s*=>\s*\{/)?.[1]?.split(/\}\s*\)\s*;?\s*\}/)?.[0];
40+
assert.lengthOf(callback?.match(/if\s*\(/g), 2);
4041
```
4142
4243
Your `if` statement should check if `a.title` is greater than `b.title`.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ assert.isFunction(sortSongs);
2222
Your `sortSongs` function should use arrow function syntax.
2323

2424
```js
25-
assert.match(code, /const|let\s+sortSongs\s*=\s*\(\s*\)\s*=>\s*{\s*}\s*;?/)
25+
assert.match(code, /(const|let)\s+sortSongs\s*=\s*\(\s*\)\s*=>\s*{\s*}\s*;?/)
2626
```
2727

2828
# --seed--

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Start by removing the `printGreeting`, `printMessage`, and `addTwoNumbers` funct
1616
You should not have a `printGreeting` function.
1717

1818
```js
19-
assert.notMatch(code, /const printGreeting = () => {/);
19+
assert.notMatch(code, /const printGreeting = \(\) => {/);
2020
```
2121

2222
You should not have a `printMessage` function.

0 commit comments

Comments
 (0)