freeCodeCamp/guide/english/certifications/javascript-algorithms-and-d.../basic-javascript/manipulating-complex-objects/index.md

109 lines
1.7 KiB
Markdown
Raw Normal View History

2018-10-12 19:37:13 +00:00
---
title: Manipulating Complex Objects
---
## Manipulating Complex Objects
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
Heres the example:
```javascript
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CD",
"8T",
"LP"
],
"gold": true
}
// Add record here
];
```
Heres a solution:
After string `// Add record here` we add new album to the `myMusic`. You need to start from `,`. And you can just copy already created album:
```javascript
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CD",
"8T",
"LP"
],
"gold": true
}
```
and paste after `,`:
```javascript
// Add record here
,
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CD",
"8T",
"LP"
],
"gold": true
}
];
```
Now, you can change values your album:
```javascript
// Add record here
,
{
"artist": "Deep Purple",
"title": "Smoke on the water",
"release_year": 1976,
"formats": [
"CD",
"8T",
"LP"
],
"gold": true
}
];
```
Heres a full solution:
```javascript
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CD",
"8T",
"LP"
],
"gold": true
},
// Add record here
{
"artist": "Deep Purple",
"title": "Smoke on the water",
"release_year": 1976,
"formats": [
"CD",
"8T",
"LP"
],
}
];
```