I’m confused about how to do this exercise and there’s no hint page:
I don’t understand how you enter another album into the existing data structure without overwriting the data that’s already there. It says “If you want to add more album records, you can do this by adding records to the top level array,” but it’s not clear how you do that.
I notice they’ve updated the instructions on this challenge since I last looked. Read them very carefully, and the one thing you are missing is mentioned there…
I looked over the instructions again, still lost. I understand that myMusic is an array, but it seems like the albums should be myMusic[1] and myMusic[2], and I can’t get that to work.
Your intuition is sensible, but javascript doesn’t quite work the way you are thinking.
Presumably you want myMusic[1] and myMusic[2] to be the first and second item in the myMusic array?
Firstly, computers start counting at zero, so the reference in the error message to myMusic[1] is actually the test runner complaining that you haven’t set an object as the second item in the array. This is true, you’ve tried to set it as an array that contains an object:
[{.....}] instead of just {.....}
However, setting each item in the array the way you have doesn’t quite work like that in javascript either.
To simplify, you have an array with one item, eg, [0]
To add to that array, add a comma and the new item eg [0, 1]
The same principle is used whether you are adding strings, numbers or objects - use a comma to separate them.
MANY people have missed the comma in the past - read through this and see how many people tore their hair out over the comma…it’s reassuring to know you weren’t the only one :
P.s this is my first FCC contribution and I have been coding for one month now,
Spoiler alert below this explanation!!!
There is a very discreet but VERY important comma missing at the end the first myMusic element,
This is a simple comma after the closing brace for the first element. By adding in this comma, the computer then recognises that this element is closed, and you can open a new element within the same Array.