Basic JavaScript - Manipulating Complex Objects

Tell us what’s happening:
Not that big of a deal but, what if I wanted to add new artist without typing on the nested array that’s already written? That is, can I add:

myMusic.artist: “Jhon Denver”? What if I wante to push a new artist instead of entering the complex object?

  **Your code so far**
const myMusic = [
{
  "artist": "Billy Joel",
  "title": "Piano Man",
  "release_year": 1973,
  "formats": [
    "CD",
    "8T",
    "LP"
  ],
  "gold": true
},
{
  "artist": "Jhon Denver",
  "title": "Time in a bottle",
  "release_year": 1965,
  "formats": [
    "CD",
    "8T",
    "LP"
  ],
  "gold": true
}
];


  **Your browser information:**

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

Challenge: Basic JavaScript - Manipulating Complex Objects

Link to the challenge:

You would use push() as you have before, and pass an object as its argument.

myMusic.push({
  artist: "Don Jenver"
});
1 Like

Thanks for your help.