Manipulating Complex Objects New Album to musicArray

Manipulating Complex Objects New Album to musicArray
0

#1

Tell us what’s happening:
Add a new album to the myMusic array. Add artist and title strings, release_year number, and a formats array of strings.

I tried several different ways but cannot solve it. Please help

Your code so far

var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  ];
var myMusic[1] = [
 {
  "artist": "Sublime",
  "title": "40 Oz's To Freedom",
  "releaser_year": 1992
  "formats": [
     "CD",
     "MP3",
     "KT" ],
    "gold": true  
  }
 // Add record here
];

Your browser information:

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

Link to the challenge:


#2

You have two issues with your solution.

  1. The first var for myMusic was the only var needed. In the first part of your code (the part already given), myMusic contains an array with one element (an object /album). Then, you attempt to re-declare myMusic, which errors out.

  2. Even if you did not try to re-declare myMusic, the part myMusic[1] = [ is going to assign an array containing an object/album to the 2nd element of myMusic. You only want to assign another object/album.

  3. Lastly, you have a syntax error in the object of the array you try to assign to myMusic’s second element. Remember, objects have property/value pairs which are separated by commas.


#3
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
   {
     "artist": "Sublime",
  "title": "40 Oz's To Freedom",
  "releaser_year": 1992,
  "formats": [
     "CD",
     "MP3",
     "KT" ],
    "platinum": true
   }// Add record here
];

I know this is also incorrect. I’m just completely missing out on how I am suppose to correctly add the second element.


#4

You are sooooo close! What you want in the end is an array with two objects in it. Hint: How do you separate elements in an array?


#5

var myMusic = [
{
“artist”: “Billy Joel”,
“title”: “Piano Man”,
“release_year”: 1973,
“formats”: [
“CS”,
“8T”,
“LP” ],
“gold”: true
},
{
“artist”: “Sublime”,
“title”: “40 Oz’s To Freedom”,
“releaser_year”: 1992,
“formats”: [
“CD”,
“MP3”,
“KT” ],
“platinum”: true,
}// Add record here
];

Almost there still?


#6

Oh I got it! Thank you so much!!! My only mistake at the end was an “r” on the end of “relase” hahaha