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

Create an array of objects

im not understanding how it wants me to write out the variable

script.js
var objects =[ "blade", "wolves", "hearts" ];
index.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JavaScript Objects</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
Gustavo Winter
Gustavo Winter
Courses Plus Student 27,382 Points

Hi, the task ask you to add three object literals. In other words, the objects array should have three values. Each object should have 2 property/value pairs.

In your code you make an array with tree objects but without any property/value.

Look this, i'm sure you will be able to increase your code:

          var objects = [
  {
    name: 'Adam',
    age: 17    
  }, 
  {
    name: 'Eva',
    age: 21
  }, 
  {
    name: 'Jeremias',
    age: 33
  } 
];

1 Answer

Amrit Pandey
Amrit Pandey
17,595 Points

So, I cannot completely understand your question but,

by array of objects it means we have to create an array containing objects

var someObject = {};

This is an object,

var someArray = [];

This is an array,

var arrayOfObjects = [
         {object1},
         {object2},
         {object3},
         ....
]

This is an array of objects.