# freeCodeCamp - Manipulating Complex Objects

freeCodeCamp - Manipulating Complex Objects
0

#1
``````var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}

];
``````

Hint:add a comma and create a similar object as above. ignore any laxcomma warnings.

#2

Is there a question here?

Iâ€™ll assume that youâ€™re confused about what to do.

If you have an array of objects:

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

Here is an array of objects with only one object. 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"
]
},                        // end of first object
{                         // start of second object
"name" : "Goldie",
"species" : "fish",
"food" : [
"fish food"
]
}                         // end of second object
];                          // end of array of objects
``````

You could chain on as many objects as you want, adding them to your array of objects.

#3

thanks the `,` after each objects was the problem I had

#4

I solved this one, but can someone explain to me why the â€śrelease yearâ€ť string is written with an underscore?

#5

`"release_year"` can be used with dot notation `.release_year` or bracket notation `["release_year"]`

`"release year"` can only be used with bracket notation `["release year"]` because it is not a valid identifier

#6
``````var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ,],
"gold": true

];{
"artist": "Cesare Siepi",
"title": "Operatic Arias For Bass",
"release_year": 1965,
"formats": [
"LP",
"Mono",
"RE",],
"gold": false

}
This is not working, what am I doing wrong here?``````

#7

The lines below:

``````} // Add record here
];{
``````

should be:

``````} // Add record here
,{
``````

Also, you need to add a closing bracket ] after the very last line of code which contains the closing squiggly bracket. myMusic is an array represented between the two square brackets [ ] which contains objects which are represented between the squiggly brackets { }, and the comma between the objects separates the objects in the array.

#8
``````var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
},
{
"title"**_: "Chester Bennington"_**,
"release_year": 2017,
"formats": [
"We are sorry for you.",
"We are sorry for your family."
]
}
];``````

#9

had an error with the â€śrelease_yearâ€ť: 2007, on my code,

didnt work till i changed the year to 1973

#10

var myMusic = [
{
â€śartistâ€ť: â€śBilly Joelâ€ť,
â€śtitleâ€ť: â€śPiano Manâ€ť,
â€śrelease_yearâ€ť: 1973,
â€śformatsâ€ť: [ â€śCSâ€ť, â€ś8Tâ€ť, â€śLPâ€ť ],
â€śgoldâ€ť: true
},
{
â€śartistâ€ť: â€śCesare Siepiâ€ť,
â€śtitleâ€ť: â€śOperatic Arias For Bassâ€ť,
â€śrelease_yearâ€ť: 1965,
â€śformatsâ€ť: [â€śLPâ€ť, â€śMonoâ€ť, â€śREâ€ť],
â€śgoldâ€ť: false
}
];

I think is can running, Episs2man

#11

Hi @rgmorales11, based on the challenge requirements, we really need to use an underscore because this is a fixed rule. If not, then you will receive a code error:

In my own opinion, I never tried to see the difference between having a space or underscore but for best practice, coders use underscore. See for your self here:

`**`http://javascript.crockford.com/code.html`**`

#12