Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Matt Bloomer
10,608 Pointsarrays and objects
Why isn't what I have working?
var objects= [{
var objects = [ {question: "one + two", answer: "three" }
{question: "two + two", answer: "four"}
{question: "three + two", answer: "five"}
];
];
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Objects</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
4 Answers

Marcus Parsons
15,718 PointsHi Matt,
It looks like you have two sets of var objects
when you only want one. You have the syntax almost correct inside of the array, except that each object has to be separated by a comma except for the very last object.
var objects = [
//comma inserted after this object
{question: "one + two", answer: "three" },
//comma inserted after this object
{question: "two + two", answer: "four"},
//no comma here because it is last object
{question: "three + two", answer: "five"}
];

Matt Bloomer
10,608 PointsI don't understand the answer.

Marcus Parsons
15,718 PointsYou start off with an empty array literal and create the variable objects
which is equal to that empty array literal which is []. Next, you put those 3 objects into the array. Each object is surrounded by curly braces {}. Each object has to be separated from the object before it, so you need a comma after the ending of each object.

Matt Bloomer
10,608 PointsI think I tried that, and it didn't work.

Marcus Parsons
15,718 PointsIt does work 100%. You must copy and paste correctly.

Matt Bloomer
10,608 PointsWhatever...I will just get help from someone else at another time.

Marcus Parsons
15,718 PointsI gave you the correct explanation and correct answer. If you copy and paste the code I gave you (which explains what I did), you'll see that the challenge passes. That is a poor attitude to have to someone who's trying to help you.