Kenan
January 30, 2020, 4:34pm
1
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CD",
"8T",
"LP"
],
"gold": true
}
{
artist: "Deep Purple",
title: "Smoke on the water",
release_year: 1976,
formats: ["CD", "8T", "LP"]
} // Add record here
];
Does anyone know why this isn´t working?
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it 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.
Note: Backticks are not single quotes.
Remeber that when you are writing an array, you must separate its elements with commas.
Kenan
January 30, 2020, 5:11pm
4
Aren´t they seperated with commas?
Your array contains two items, but there is no comma between them.
Kenan
January 30, 2020, 5:16pm
6
Please could you tell me the line, I don´t get it.
What are the items in your array?
Kenan
January 30, 2020, 5:24pm
9
The items in my arry are CD,8T and LP
I’m talking about the array myMusic
.
You have an array of objects that contain arrays!
myMusic
is an array!
lasjorg
January 30, 2020, 6:56pm
12
You have an array with two objects in it. But the two objects are not separated by a comma as needed.
Basic JavaScript: Manipulating Complex Objects
Note
You will need to place a comma after every object in the array, unless it is the last object in the array.
You have:
const array = [
{
...code
}
{
...code
}
]
Should be:
const array = [
{
...code
},
{
...code
}
]
1 Like