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 trial

JavaScript JavaScript Loops, Arrays and Objects Tracking Data Using Objects Create an Array of Objects

Aaron Noble
Aaron Noble
6,559 Points

Inside the array literal, add three object literals. In other words, the objects array should have three values.

It says to :

Inside the array literal, add three object literals. In other words, the objects array should have three values. Each object should have 2 property/value pairs.

I've created the objects array, with 3 different object literals. Each object literal has 2 key : value pairs. What am I doing wrong? Anything to help,

Thank you,

Aaron

script.js
var objects = [
  person1{
    name : 'Aaron',
    age : 23,
  },
  person2{
    name : 'Svetlana',
    age : 45,
  },
  person3{
    name : 'Bruce',
    age : 43,
  },
];
index.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JavaScript Objects</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>

2 Answers

Steven Parker
Steven Parker
229,657 Points

You're pretty close, but when defining an object literal start with an open brace. There should be no name preceding it.

Also, commas separate the properties of an object, and also the elements of an array. But there should not be a comma after the last property or element.

Aaron Noble
Aaron Noble
6,559 Points

Nice catches, that all makes sense. Thank you for the help on this problem!!

No offense, but it's not working.

Steven Parker
Steven Parker
229,657 Points

Your code probably has different issue(s). Start a fresh question using the "get help" button in the challenge after entering your code.