Learn basic string and array methods by building a music player step 9

Hi im stuck. Im trying to use the spreed operator but i cant get it to work.
The task “Inside the userData object create a songs property. For the value, spread allSongs into an array.”

My code so far

let userData = {
const songs = […allSongs];

some times you just have to ask to solve the problem :smiley:

1 Like

Welcome to the forum @daniel.petersson83


Notice the red underline? This indicates that the syntax is incorrect.

You are asked to create a property.

Happy coding

1 Like

It seems like you’re using the spread operator correctly, but there’s a syntax issue. Here’s the corrected code:


This code will create a userData object with a songs property containing all the elements from the allSongs array.

1 Like

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

This exercise does not ask the user to create an object. It states that userData is an object. The request is to create a property.

In the OP example (which I was also doing), a variable is being declared instead of defining a property of an object.

A search on how to create properties for objects in JavaScript shows examples of the correct syntax for this exercise.