Need help with this challenge, Manipulating Complex Objects

Whole code, always, so I can see the whole array, not just what you write
But the {[ at the beginning of what you wrote is not right

Also, you have the second property missing a comma at the end

var myMusic = [
{
“artist”: “Billy Joel”,
“title”: “Piano Man”,
“release_year”: 1973,
“formats”: [
“CD”,
“8T”,
“LP”
],
“gold”: true
}
// Add record here
{
“artist”:“Smokey”,
“title”:“Needeles and Pains”,
“release_year”: “1970”,
“formats”: [“CD”, “Cassette”,“LP”]
}];

You are missing a comma between the first and second object, all elements in an array should be separated by commas

var myMusic = [
{
“artist”: “Billy Joel”,
“title”: “Piano Man”,
“release_year”: 1973,
“formats”: [
“CD”,
“8T”,
“LP”
],
“gold”: true
}
// Add record here
{
“artist”:“Smokey”,
“title”:“Needeles and Pains”,
“release_year”: “1970”,
“formats”: [“CD”, “Cassette”,“LP”,]
}];

There is not a comma between the closing curly bracket of the first object and the opening curly bracket of the second object: all elements in an array must be separated by commas

var myMusic = [
{
“artist”: “Billy Joel”,
“title”: “Piano Man”,
“release_year”: 1973,
“formats”: [
“CD”,
“8T”,
“LP”
],
“gold”: true
}
// Add record here
{
“artist”:“Smokey”,
“title”:“Needeles and Pains”,
“release_year”: “1970”,
“formats”: [“CD”, “Cassette”,“LP”,]
},];

Saying my first curly braces is a syntax error… I want to thank U for been this patient to help… Still never gotten it right… How difficult…

You have added the comma in the wrong place, look the comment I added here, the arrow points to the comma between the closing curly bracket of the first object and the opening curly bracket of the second object

var myMusic = [
  {
   /* this is the first object that already exist */
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CD",
      "8T",
      "LP"
    ],
    "gold": true
  }
, /* <-- this comma is missing in your code */
  { /* you need to create a second object here */ }
]
1 Like

ooh my goodness, almost done, just one left… Thank U, thank U… Thank U…

1 Like

I got it now, i am so glad and relieved , ooh my goodness… Thank U so much… U are blessed and kind… God bless U.

Did you fix it @Karons arons?

in my opinion there shouldn’t be “” around the property names, second why are you using
“ ” instead of " " (Be aware of this,)

should be:

artist: “Billy Joel”, title: “Piano Man”,

// object in an array

var myMusic = [
{ "artist": "Billy Joel", "title": "Piano Man",
"formats": ["CD","8T","LP"], "gold": true},

// Second Record

{ "artist": "Smokey", "title": "Needles and Pains", "release_year": "1970",
"formats": ["CD", "Cassette", "LP"] }
];

document.write(myMusic[0].artist + "<br>"); // displays Billy Joel
document.write(myMusic[1].artist + "<br>"); // displays Smokey
document.write(myMusic[1].formats[2] + "<br>"); // displays LP



  1. It is not a method, it’s a property. Edit: The type of quot i think just comes from the forum when not posting code formatted using the code formatting option.

  2. The challenge is using the formatting of having the property name/key in quotes, likely done to simulate an API using JSON.

Other notes
JSON requires double quotes to be used around strings and property names. Single quotes are not valid.

2 Likes

@lasjorg ok thanks for pointing that out, I didn’t know that (edited it)

Yes right, thanks… That comma got me there, but it took me time to figure out we hv an Array inside an Array.

A+ to ieahleen

Props for staying patient.