Manipulating Complext JavaScript issues. Can't figure out the syntax

Manipulating Complext JavaScript issues. Can't figure out the syntax
0

#1

Hey, so I’m working through the program, and loving it so much but I am beyond stumped on this lesson.

var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  {
    "artist": "Not Billy Joel", // Add record here
    "title": "Some Other Song",
    "release_year": 3113,
    "formats": [ 
      "AB", 
      "CD", 
      "EF" ]
  }
];

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


#2

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.


#3

Since what you posted is the original code, we don’t know what you have tried to give you syntax errors or what you tried that did not provide the correct answers.

Remember, myMusic is an array holding one object (album) currently. You just need to add another album (object). Remember, that arrays have elements which are separated by commas.

EXAMPLE:

var myArray = ['element1', 'element2', 'element3'];

#4

You should take a look at this previous challenge:

There are important lessons within the challenge that you posted:

Whenever you see [ ], you’re working with an array, and whenever you see {property: value}, you’re working with an object (or JSON, but that comes later).

In previous lessons, you would assign arrays and objects to variables. BUT you can assign those values to just about anywhere. An object can go inside another object, an array can go inside an object, an object can go inside an array that’s inside an array that’s inside an object and it can go on and on and on.

For the purpose of this challenge, it’s telling you that there’s already an object {} inside an array []. It just wants you to add another object {} inside that same array.


#6

You need to post all the code, not just a section of it.

We should still see the original (below) with your code added in. Replace the // Add record here with the album object you created.

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

#7

@ardn-jordan: Note that the elements must be comma separated.


#8

@ardn-jordan all you need, is to add a comma between the 2 brackets (see pic).
The reading stated that UNLESS it is the last "record"
in the array, place a comma between records. Hope this helps :slight_smile: