Manipulating Complex Objects 201

Manipulating Complex Objects 201
0

#1

Tell us what’s happening:
i dont understand this please help

Sometimes you may want to store data in a flexible Data Structure. A JavaScript object is one way to handle flexible data. They allow for arbitrary combinations of strings, numbers, booleans, arrays, functions, and objects.

Here’s an example of a complex data structure:

var ourMusic = [
{
“artist”: “Daft Punk”,
“title”: “Homework”,
“release_year”: 1997,
“formats”: [
“CD”,
“Cassette”,
“LP” ],
“gold”: true
}
];
This is an array which contains one object inside. The object has various pieces of metadata about an album. It also has a nested “formats” array. If you want to add more album records, you can do this by adding records to the top level array.

Objects hold data in a property, which has a key-value format. In the example above, “artist”: “Daft Punk” is a property that has a key of “artist” and a value of “Daft Punk”.

JavaScript Object Notation or JSON is a related data interchange format used to store data.

{
“artist”: “Daft Punk”,
“title”: “Homework”,
“release_year”: 1997,
“formats”: [
“CD”,
“Cassette”,
“LP”
],
“gold”: true
}
Note
You will need to place a comma after every object in the array, unless it is the last object in the array.

Instructions
Add a new album to the myMusic array. Add artist and title strings, release_year number, and a formats array of strings.

Your code so far

var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  // Add record here
  {
    "artist": "Linkin Park",
    "title" : "Metallica",
    "release_year": 2004,
    "formats": [
      "DVD",
      "iTunes",
      "spotify"
    ],
    "gold": true
  }
];

Your browser information:

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

Link to the challenge:


#2

Have a look at how you separate several elements in an array.


#3

these code not run…


#4

A post was split to a new topic: Manipluating Complex Objects - stuck


#5

@Mkros: you need to put a comma before you add your information. Like so:

var myMusic = [
{
“artist”: “Billy Joel”,
“title”: “Piano Man”,
“release_year”: 1973,
“formats”: [
“CS”,
“8T”,
“LP” ],
“gold”: true
}
// Add record here, dont forget the comma before curly braces
,{
“artist”: “Bob Marley”,
“title”: “I shot the sheriff”,
“release_year”: 1973,
“formats”: [
“CS”,
“8T”,
“LP” ],
“gold”: true
}
];

let me know if it works chief