Adding a New Album to var myMusic

Adding a New Album to var myMusic
0.0 0

#1

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

I’m having some trouble understanding what the challenge is asking for.
I have read the instructions over several times and thought I understood it but every time I begin the code, it’s telling me it’s wrong? so I’m not really sure what I need to start with.

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

Link to the challenge:


#2

Without seeing your actual code, it is difficult to tell you much. Remember, myMusic is just an array of elements. The starting code declares myMusic as an array with one element which is an object. The object represents a single album. All you need to do is create another object and put it as a second element of myMusic. You already know what an array’s syntax looks like and you are given an example of a valid album/object with the existing code, so it should be fairly straight forward.

To enter a code block into the forum, 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

hmm true. well here’s my code so far alongside the example on top (Billy Joel record)
var myMusic = [
{
“artist”: “Billy Joel”,
“title”: “Piano Man”,
“release_year”: 1973,
“formats”: [
“CS”,
“8T”,
“LP” ],
“gold”: true
}
{//your record here
"artist": “Beatles”,
“title”: “White Album”,
“release_year”: 1968,
“formats”: [
“Vinyl”,
“Cassette”,
“CD”],
“gold”: true
};


#4

You are close. The problem is you are missing two very important characters. Since myMusic is an array, you need to make sure the array is surrounded by two different characters. The first character is there, but you accidentally deleted the other character.

Also, how do you separate elements in an array? You are missing that character also between the two elements.


#5

Don’t you separate elements in an array by semi colon? I fixed the code and ran it but it’s still not working. here’s the new code:

var myMusic = [
{
“artist”: “Billy Joel”,
“title”: “Piano Man”,
“release_year”: 1973,
“formats”: [
“CS”,
“8T”,
“LP” ],
“gold”: true
}
];
var myMusic = [
{
“artist”: “Beatles”,
“title”: “White Album”,
“release_year”:1968,
“formats”: [
“Vinyl”,
“Cassette” ],
“gold”: true
}
];


#6

You were much closer in your first attempt. All you have done with your second code attempt is try to re-declare myMusic with a single object/album which is different from the original. Remember, you only declare variables one time. You do not need to reassign anything to the original variable myMusic. Just add another element to it.

You might want to review the following challenge on arrays.


#7

ahhh that makes more sense. thank you so much for the tips! i’ll check it out.