Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBrendan Thomas
19,661 PointsStep 2 is contradicting Step 1?
Step 1 is to make an empty array. Step two is to add objects into the array. When I add objects to the array, it tells me that step 1 no longer passes. Obviously I can't have an empty array and an array with objects in it at the same time. I think I'm coding it right, but my third object is giving me a different color for the property names.
var objects = [
{
name: 'one',
amountTo: 1
}
{
name: 'two',
amountTo: 2
}
{
name: 'three',
amountTo: 3
}
];
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Objects</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
2 Answers
Damien Watson
27,419 PointsHi Brendan,
When you add objects into an array, they must be separated by a comma. So your code should look like this:
var objects = [
{
name: 'one',
amountTo: 1
},
{
name: 'two',
amountTo: 2
},
{
name: 'three',
amountTo: 3
}
];
Brendan Thomas
19,661 PointsYup I just realized that right after I posted this. Thanks for the help!
Damien Watson
27,419 PointsNo probs.