fix(curriculum): tests passing with seed code in Music player (#55586)
Co-authored-by: Sem Bauke <sem@freecodecamp.org>pull/55940/head
parent
6a24f8a744
commit
214f506e4c
|
@ -30,19 +30,19 @@ assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*{\s*[\s\S]*?\}\s*;?/);
|
|||
You should use the `sort()` method on `userData?.songs`.
|
||||
|
||||
```js
|
||||
assert.match(code, /userData\?\.songs\.sort\(/)
|
||||
assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*{\s*userData\?\.songs\.sort\(/);
|
||||
```
|
||||
|
||||
Your `sort()` method should have a callback function that uses arrow syntax.
|
||||
|
||||
```js
|
||||
assert.match(code, /userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*/)
|
||||
assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*{\s*userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*/);
|
||||
```
|
||||
|
||||
The callback of your `sort()` method should return `Math.random() - 0.5`.
|
||||
|
||||
```js
|
||||
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*;?/);
|
||||
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*;?/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
|
|
@ -33,10 +33,11 @@ Inside your callback function, add another `if` statement to check if `a.title`
|
|||
|
||||
# --hints--
|
||||
|
||||
You should have an `if` statement inside your callback function.
|
||||
You should have a second `if` statement inside your callback function.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(/);
|
||||
const callback = code.split(/const\s+sortSongs\s*=\s*\(\s*\)\s*=>\s*\{/)?.[1]?.split(/\}\s*\)\s*;?\s*\}/)?.[0];
|
||||
assert.lengthOf(callback?.match(/if\s*\(/g), 2);
|
||||
```
|
||||
|
||||
Your `if` statement should check if `a.title` is greater than `b.title`.
|
||||
|
|
|
@ -22,7 +22,7 @@ assert.isFunction(sortSongs);
|
|||
Your `sortSongs` function should use arrow function syntax.
|
||||
|
||||
```js
|
||||
assert.match(code, /const|let\s+sortSongs\s*=\s*\(\s*\)\s*=>\s*{\s*}\s*;?/)
|
||||
assert.match(code, /(const|let)\s+sortSongs\s*=\s*\(\s*\)\s*=>\s*{\s*}\s*;?/)
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
|
|
@ -16,7 +16,7 @@ Start by removing the `printGreeting`, `printMessage`, and `addTwoNumbers` funct
|
|||
You should not have a `printGreeting` function.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /const printGreeting = () => {/);
|
||||
assert.notMatch(code, /const printGreeting = \(\) => {/);
|
||||
```
|
||||
|
||||
You should not have a `printMessage` function.
|
||||
|
|
Loading…
Reference in New Issue