mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
feat(curriculum): update music player to use specific assert methods - first 5 steps (#53756)
This commit is contained in:
+24
-6
@@ -16,16 +16,28 @@ Start by accessing the `#playlist-songs`, `#play`, and `#pause` elements with th
|
||||
|
||||
# --hints--
|
||||
|
||||
You should have a variable called `playlistSongs`.
|
||||
|
||||
```js
|
||||
assert.isDefined(playlistSongs);
|
||||
```
|
||||
|
||||
You should use `document.getElementById()` to get the `#playlist-songs` element.
|
||||
|
||||
```js
|
||||
assert.match(code, /document\.getElementById\(\s*('|"|`)playlist\-songs\1\s*\)/);
|
||||
```
|
||||
|
||||
You should assign the `#playlist-songs` element to the variable `playlistSongs`. Don't forget to use `const` to declare the variable.
|
||||
You should assign the `#playlist-songs` element to the variable `playlistSongs`.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+playlistSongs\s*\=\s*document\.getElementById\(\s*('|"|`)playlist\-songs\1\s*\)/);
|
||||
assert.equal(playlistSongs, document.getElementById('playlist-songs'));
|
||||
```
|
||||
|
||||
You should have a variable called `playButton`.
|
||||
|
||||
```js
|
||||
assert.isDefined(playButton);
|
||||
```
|
||||
|
||||
You should use `document.getElementById()` to get the `#play` element.
|
||||
@@ -34,10 +46,16 @@ You should use `document.getElementById()` to get the `#play` element.
|
||||
assert.match(code, /document\.getElementById\(\s*('|"|`)play\1\s*\)/);
|
||||
```
|
||||
|
||||
You should assign the `#play` element to the variable `playButton`. Don't forget to use `const` to declare the variable.
|
||||
You should assign the `#play` element to the variable `playButton`.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+playButton\s*\=\s*document\.getElementById\(\s*('|"|`)play\1\s*\)/);
|
||||
assert.equal(playButton, document.getElementById('play'));
|
||||
```
|
||||
|
||||
You should have a variable called `pauseButton`.
|
||||
|
||||
```js
|
||||
assert.isDefined(pauseButton);
|
||||
```
|
||||
|
||||
You should use `document.getElementById()` to get the `#pause` element.
|
||||
@@ -46,10 +64,10 @@ You should use `document.getElementById()` to get the `#pause` element.
|
||||
assert.match(code, /document\.getElementById\(\s*('|"|`)pause\1\s*\)/);
|
||||
```
|
||||
|
||||
You should assign the `#pause` element to the variable `pauseButton`. Don't forget to use `const` to declare the variable.
|
||||
You should assign the `#pause` element to the variable `pauseButton`.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+pauseButton\s*\=\s*document\.getElementById\(\s*('|"|`)pause\1\s*\)/);
|
||||
assert.equal(pauseButton, document.getElementById('pause'));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+24
-6
@@ -13,16 +13,28 @@ Assign them to variables named `nextButton`, `previousButton`, and `shuffleButto
|
||||
|
||||
# --hints--
|
||||
|
||||
You should have a variable called `nextButton`.
|
||||
|
||||
```js
|
||||
assert.isDefined(nextButton);
|
||||
```
|
||||
|
||||
You should use `document.getElementById()` to get the `#next` element.
|
||||
|
||||
```js
|
||||
assert.match(code, /document\.getElementById\(\s*('|"|`)next\1\s*\)/);
|
||||
```
|
||||
|
||||
You should assign the `#next` element to the variable `nextButton`. Don't forget to use `const` to declare the variable.
|
||||
You should assign the `#next` element to the variable `nextButton`.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+nextButton\s*\=\s*document\.getElementById\(\s*('|"|`)next\1\s*\)/);
|
||||
assert.equal(nextButton, document.getElementById('next'));
|
||||
```
|
||||
|
||||
You should have a variable called `previousButton`.
|
||||
|
||||
```js
|
||||
assert.isDefined(previousButton);
|
||||
```
|
||||
|
||||
You should use `document.getElementById()` to get the `#previous` element.
|
||||
@@ -31,10 +43,16 @@ You should use `document.getElementById()` to get the `#previous` element.
|
||||
assert.match(code, /document\.getElementById\(\s*('|"|`)previous\1\s*\)/);
|
||||
```
|
||||
|
||||
You should assign the `#previous` element to the variable `previousButton`. Don't forget to use `const` to declare the variable.
|
||||
You should assign the `#previous` element to the variable `previousButton`.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+previousButton\s*\=\s*document\.getElementById\(\s*('|"|`)previous\1\s*\)/);
|
||||
assert.equal(previousButton, document.getElementById('previous'));
|
||||
```
|
||||
|
||||
You should have a variable called `shuffleButton`.
|
||||
|
||||
```js
|
||||
assert.isDefined(shuffleButton);
|
||||
```
|
||||
|
||||
You should use `document.getElementById()` to get the `#shuffle` element.
|
||||
@@ -43,10 +61,10 @@ You should use `document.getElementById()` to get the `#shuffle` element.
|
||||
assert.match(code, /document\.getElementById\(\s*('|"|`)shuffle\1\s*\)/);
|
||||
```
|
||||
|
||||
You should assign the `#shuffle` element to the variable `shuffleButton`. Don't forget to use `const` to declare the variable.
|
||||
You should assign the `#shuffle` element to the variable `shuffleButton`.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+shuffleButton\s*\=\s*document\.getElementById\(\s*('|"|`)shuffle\1\s*\)/);
|
||||
assert.equal(shuffleButton, document.getElementById('shuffle'));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+14
-2
@@ -13,10 +13,22 @@ Create an empty `allSongs` array.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should use `const` to create an empty `allSongs` array.
|
||||
You should have a variable called `allSongs`.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+allSongs\s*=\s*\[\s*\]/)
|
||||
assert.isDefined(allSongs)
|
||||
```
|
||||
|
||||
You should assign an array to your `allSongs` variable.
|
||||
|
||||
```js
|
||||
assert.isArray(allSongs)
|
||||
```
|
||||
|
||||
Your array should be empty.
|
||||
|
||||
```js
|
||||
assert.isEmpty(allSongs)
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
-6
@@ -13,12 +13,6 @@ Start by using the `let` keyword to declare a new variable called `userData` and
|
||||
|
||||
# --hints--
|
||||
|
||||
You should have a variable called `userData`.
|
||||
|
||||
```js
|
||||
assert.isDefined(userData);
|
||||
```
|
||||
|
||||
You should use the `let` keyword to create the `userData` variable.
|
||||
|
||||
```js
|
||||
|
||||
+8
-2
@@ -23,10 +23,16 @@ Inside the `userData` object create a `songs` property. For the value, spread `a
|
||||
|
||||
# --hints--
|
||||
|
||||
Your `userData` object should have a `songs` key set to `[...allSongs]`.
|
||||
Your `userData` object should have a key called `songs`.
|
||||
|
||||
```js
|
||||
assert.match(code, /songs\s*:\s*\[\s*\.\.\.allSongs\s*\]\s*,?/);
|
||||
assert.property(userData, "songs");
|
||||
```
|
||||
|
||||
Your `songs` property should have a value of `[...allSongs]`.
|
||||
|
||||
```js
|
||||
assert.deepPropertyVal(userData, "songs", [...allSongs]);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
Reference in New Issue
Block a user