Skip to content

Commit

Permalink
fix(curriculum): update grammar and tests music 38
Browse files Browse the repository at this point in the history
Checklist:

<!-- Please follow this checklist and put an x in each of the boxes, like this: [x]. It will ensure that our team takes your pull request seriously. -->

- [x] I have read and followed the [contribution guidelines](https://contribute.freecodecamp.org).
- [x] I have read and followed the [how to open a pull request guide](https://contribute.freecodecamp.org/#/how-to-open-a-pull-request).
- [x] My pull request targets the `main` branch of freeCodeCamp.
- [x] I have tested these changes either locally on my machine, or GitPod.

<!--If your pull request closes a GitHub issue, replace the XXXXX below with the issue number.-->

Closes freeCodeCamp#53700

<!-- Feel free to add any additional description of changes below this line -->
  • Loading branch information
Supravisor committed Apr 28, 2024
1 parent 5cbe0b7 commit bb13f06
Showing 1 changed file with 8 additions and 5 deletions.
Expand Up @@ -7,23 +7,26 @@ dashedName: step-38

# --description--

Before playing the song, you need to make sure it starts from the beginning. This can be achieved by the use of the `currentTime` property of the `audio` object.
Before playing the song, you need to make sure it starts from the beginning. This can be achieved by the use of the `currentTime` property on the `audio` object.

Add an `if` statement to check whether the `userData?.currentSong` is `null` or if `userData?.currentSong.id` is strictly not equal `song.id`. Inside `if` block, set the `currentTime` property of the `audio` object to `0`.
Add an `if` statement to check whether the `userData?.currentSong` is falsy *OR* if `userData?.currentSong.id` is strictly not equal `song.id`. This condition will check if no current song is playing or if the current song is different from the one that is about to be played.

Inside `if` block, set the `currentTime` property of the `audio` object to `0`.

# --hints--

You should create an `if` statement with the condition `userData?.currentSong === null || userData?.currentSong.id !== song.id`.
Despite the use of the logical *OR* operator, order in this statement is important, as `userData?.currentSong.id` depends on the existence of `userData?.currentSong`.

Don't forget to include optional chaining.

```js
assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\|\|\s*userData\?\.currentSong\.id\s*!==\s*song\.id\s*\)\s*\{\s*/)
assert.match(code, /if\s*\(\s*(?:(?:!userData\?\.currentSong|\s*userData\?\.currentSong\s*===\s*null)\s*\|\|\s*userData\?\.currentSong\.id\s*!==\s*song\.id\s*|\s*userData\?\.currentSong\.id\s*!==\s*song\.id\s*\|\|\s*(?:!userData\?\.currentSong|\s*userData\?\.currentSong\s*===\s*null))\s*\)\s*\{\}/)
```

You should set `audio.currentTime` to `0` inside your `if` block.

```js
assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\|\|\s*userData\?\.currentSong\.id\s*!==\s*song\.id\s*\)\s*\{\s*audio\.currentTime\s*=\s*0\s*;?\s*\}/)
assert.match(code, /if\s*\(\s*(?:(?:!userData\?\.currentSong|\s*userData\?\.currentSong\s*===\s*null)\s*\|\|\s*userData\?\.currentSong\.id\s*!==\s*song\.id\s*|\s*userData\?\.currentSong\.id\s*!==\s*song\.id\s*\|\|\s*(?:!userData\?\.currentSong|\s*userData\?\.currentSong\s*===\s*null))\s*\)\s*\{\s*audio\.currentTime\s*=\s*0\s*;?\s*\}/)
```

# --seed--
Expand Down

0 comments on commit bb13f06

Please sign in to comment.