Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299.
It is possible create a new array, but you need add a index for new album . Remember that the myAlbum “Billy Joel” is on index [0]. So we need add a second array for the first array, creating a multidimensional Array. There are two ways to get it. See lessons Access Multi-Dimensional Arrays With Indexes and Manipulate Arrays With push().
//The fisrt way to achieve it is using index. Create a new array, in this case below I call it var myNewAlbum and after apply that new array as a new index for array myAlbum.
//Now, just replace the last line using .push() to add the new array for myMusic like that: myMusic.push(myNewAlbum);
Test both yourself.
//Data structure is pretty important concept in computing. Check other explanation sources about Data Structure, like wikipedia. I reaaly hope that be a help.
Yes randelldawson. I checked again and the code was wrong due sintaxe. I was using brackets [ ] , to start a new Array, but It was wrong , because bracket refer to external and first array. The new array need start and finish with braces { }.
I put a new answer using two solutions and both work well:
//below using .push();
var myNewAlbum =
{
“artist”: “Skank”,
“title”: “Jack Tequila”,
“release_year”: 1994,
“formats”: [
“CS”, “8T”, “LP”]
};
myMusic.push(myNewAlbum);
//Below using a new index, just replacing the last line above:
myMusic[1] = myNewAlbum;