I can't uderstand how it works. Help me, please

I can't uderstand how it works. Help me, please
0

#1

Tell us what’s happening:

Your code so far

var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  
  // Add record here
];
myMusic.push("artist: Smash", "title: Life",
    "release_year: 2006", "formats: CD");

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:56.0) Gecko/20100101 Firefox/56.0.

Link to the challenge:


#2

There are a few things wrong here:

  1. You should push an object. Objects have a curly braces ({}) around them.
  2. You put quotation marks around the entire key-value pair. But you need to wrap the key in quotes and the value (if it is a string) as well.
  3. “formats” must be an array of strings.

Just have a look at the object that is already in myMusic to see how your object that you push has too look (but with different values).


#3

The reason why this isn’t working is because you’re not adding your info as an object.The array with your code is basically consisted of an object element and a set of strings. myMusic=[object,string,string,string].
In order for this to work you need to push the next element as an object , which can be done in two different ways:

  var temporaryObject={
  artist: "Smash",
  title: "Life",
  release_year: "2006",
  formats: "CD"
  };
  myMusic.push(temporaryObject);

OR

  myMusic.push({artist: "Smash",
  title: "Life",
  release_year: "2006",
  formats: "CD"});

//note the brackets { } , which indicate you’re pushing an object to an array


#4

thank you very much!!!


#5

thank you very very much!!!


#6

it’s done )))

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

];
myMusic.push({
artist: “Smash”,
title: “Life”,
release_year: 2006,
formats: [
“CD”,
“CS”]
});


#7

THE QUESTION WAS THIS
Add a new album to the myMusic array. Add artist and title strings, release_year number, and a formats array of strings.
BUT WHEN YOU LOOK AT THE SOLUTION IT’S ALL NEW WITH NEW VARIABLE, IT DOESN’T SAY THAT WE ADDED NEW ALBUM TO THE MYMUSIC, INSTEAD IT SAYS WE CREATED NEW ALBUM