From 02be3460fc6a996812ea2edd1d0e3996e2dbe704 Mon Sep 17 00:00:00 2001 From: gboeker <68177766+gboeker@users.noreply.github.com> Date: Wed, 14 Feb 2024 04:45:41 -0500 Subject: [PATCH] fix: explain method chaining for step 18 of music player (#53693) --- .../654215fe7b4a899ddceb3b60.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/654215fe7b4a899ddceb3b60.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/654215fe7b4a899ddceb3b60.md index 54762bc9116..d2ce84ed29d 100644 --- a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/654215fe7b4a899ddceb3b60.md +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/654215fe7b4a899ddceb3b60.md @@ -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 join() 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.