Learn Basic String and Array Methods by Building a Music Player - Step 9

Tell us what’s happening:

Step 9

Since users will be able to shuffle and delete songs from the playlist, you will need to create a copy of the allSongs array without mutating the original. This is where the spread operator comes in handy.

The spread operator (...) allows you to copy all elements from one array into another. It can also be used to concatenate multiple arrays into one. In the example below, both arr1 and arr2 have been spread into combinedArr:

Your code so far

let userData = {

const songs = […allSongs]



The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge Information:

Learn Basic String and Array Methods by Building a Music Player - Step 9

You’ve created a variable that contains an object (with the {}). Within objects, we don’t create new variables using const, let, or var. Objects have “properties” separated by a comma. Each property has a “key” and a “value” (a key-value pair) separated with a “:”. So to create a property with the key “song” you would only need:

{song: "array with list of songs",
artist: "array with list of artists"}

This example has two properties, one with key “song” and the other with key “artist”.

1 Like