Help please i dont understand the free codecamp question

Help please i dont understand the free codecamp question
0

#1

can someone help me solve this i don’t understand the question.


#2
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  // Add record here
];

in the above code a variable has been created which stores an array, that contains a object(a music album). The question is asking you to add another album object where it says //add record here.


#3

I’ve edited your post for readability. When you enter a code block into the forum, remember to precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.


#4

To expand on what inder wrote, you are creating an array of objects. I’m assuming that you know what an array is and assuming that you know what an object is. A simple array of objects would be:

var arr = [
  { 
    name: "Bob" 
  },
  { 
    name: "Alice" 
  }
];

It is a simple array of two simple objects. Notice the comma at the end of the fourth line - just like all arrays, the elements need to be separated by commas, even when the elements are themselves objects.

A more complex example might be this array of objects. First it is stated as an array of one object:

var myPets = [              // open array of objects
  {                         // start of first object
    "name" : "Sparky",
    "species" : "dog",
    "food" : [
      "meat",
      "dog food",
      "bones",
      "cats"
    ]
  }                         // end of first object
];                          // end of array of objects

If you want to add more, you need to separate each object with a comma:

var myPets = [              // open array of objects
  {                         // start of first object
    "name" : "Sparky",
    "species" : "dog",
    "food" : [
      "meat",
      "dog food",
      "bones",
      "cats"
    ]
  },                        // end of first object
  {                         // start of second object
    "name" : "Goldie",
    "species" : "fish",
    "food" : [
      "fish food"
    ]
  }                         // end of second object
];                          // end of array of objects

This is basically what you are doing in the challenge. You are given an array with one object and asked to add another object to make it an array of two objects.

Let us know if it is still not clear.