fix: explain method chaining for step 18 of music player (#53693)

This commit is contained in:
gboeker
2024-02-14 04:45:41 -05:00
committed by GitHub
parent 671266d48f
commit 02be3460fc

View File

@@ -7,9 +7,9 @@ dashedName: step-18
# --description--
Use the `join()` method to combine the `songsHTML` markup into a single string.
Right now the `songsHTML` is an array. If you tried to display this as is, you would see the songs separated by commas. This is not the desired outcome because you want to display the songs as a list. To fix this, you will need to join the array into a single string by using the <dfn>join()</dfn> method.
The `join()` method is used to concatenate all the elements of an array into a single string. It takes an optional parameter called `separator` which is used to separate each element of the array. For example:
The `join()` method is used to concatenate all the elements of an array into a single string. It takes an optional parameter called a `separator` which is used to separate each element of the array. For example:
```js
const exampleArr = ["This", "is", "a", "sentence"];
@@ -19,6 +19,12 @@ console.log(sentence); // Output: "This is a sentence"
Chain the `join()` method to your `map()` method and pass in an empty string for the separator.
To chain multiple methods together, you can call the `join()` method on the result of the `map()` method. For example:
```js
array.map().join();
```
# --hints--
You should add `join("")` to the existing code.