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

Tell us what’s happening:

Im not sure Im getting what is being asked, this seems to be a property for all songs. I tried songs = "allSongs"; but that did not work, I also tried songs = ["allSongs"]; and alas tried songs = allSongs; so here is another try, and it still doesn’t work… Any ideas?

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

let userData = {
  songs = "...allSongs";
}

// User Editable Region

Your browser information:

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

Challenge Information:

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

Hi @booleanmethod9

Your userData object should have a key called songs .

First you need to create a key.
Second, take a look at the example on how to copy an array.

Happy coding

The explanation talks about spreads and not keys

Hi!

I too was struggling with this step, specifically the syntax. I understood the concept/idea of what was being asked but I couldn’t find the right way to format my answer. Here is what helped.

let userData = {
songs = (This part I couldn’t get right)
}

I tried a bunch of versions, …allSongs in quotes, with the array markers at the end , and combinations thereof. I think what solved my issue was defining songs as an array of allSongs without any other punctuation […allSongs].

I think I was missing that allSongs is a variable defined in the step prior, so the … in combination with the variable should create a list of all of it’s items?

Does that help?

what im understanding is that another property needs to be defined? Thanks for your input and everything by the way…

I don’t think anything more needs to be defined, you have 99% of the code correct. I could be wrong, the only issue I see is how you’ve formatted the bit after the “songs”. I think if you adjust the = sign (I think it might be a colon instead, but I’m not 100% sure), and the quotes around …allSongs into the array brackets it should work.

let userData = {
songs = “…allSongs”;
}

the syntax of this should be

let variableHere = {
property: [value]
}
Where in this case we would use around the value because we want to pass in the array of all songs?

like this?:

let userData = {
  songs = ["...allSongs"];
}

I think it’s very close, try removing the quotes from allSongs. If you leave it in quotes you’re telling it that songs is equal to the text “…allSongs”, where you really want to tell it songs is equal to the array of the song names from the variable allSongs.

Does that help?

The help is all amazing and beautiful, but it doesn’t work my good friend. Open to any other ideas…

Ah, one other thing. I think the semi-colon should come at the end of the backets. This type of function delimits the lines with commas.

let userData = {
  songs : [...allSongs]
}

like this?:

let userData = {
  songs = [...allSongs];
}

Very close, just with the semi-colon after the last } instead of after the ]? The semicolon is used in a different context (I think) where in this context each line is separated by a comma. Since there is only one line, I don’t know you need a comma. The semi-colon outside the bracket at the end is needed because it’s the end of the function (IIRC)

let userData = {
  songs : [...allSongs]
};

"Your userData object should have a key called songs . " still my good friend. any other ideas

I see the issue, my reply missed it. The “=” sign should be a colon “:” separating songs and […allSongs] , code above is edited to reflect the correction.

why is the ; at the end though?

@NoahBurnham

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

1 Like

I’m sure this explanation isn’t technically super accurate, but the ; is outside the } because it’s ending the let userData statement, it’s not ending the definition within the { } which is where you’re stating the songs property of the userData object is equal to the array (list) of all songs.

I understand posting solutions isn’t the way. How would you suggest I have replied instead? I did try to explain the error and why it was not working from a conceptual standpoint, however, it’s a bit tricky considering I have a limited knowledge.

you can provide examples to show the syntax, just do not write a thing that can just be copied and pasted to pass the step

helping others is a good way to learn more

2 Likes

I have read your conversation I think the issue is = you should use semicolon instead of equal