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

Matt Gaboury
seal-mask
.a{fill-rule:evenodd;}techdegree
Matt Gaboury
Full Stack JavaScript Techdegree Student 1,540 Points

Don't each of my objects have two values?

Do I have to have a question and answer format like the one in the video? I tried that and that also didn't work. It says each object should have two properties/values, so are the two number values in each object no good?

script.js
var objects = [
  {object: 13, object: 20 },
  {object: 10, object: 40},
  {object: 9,  object: 30 }
];
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

your properties in the objects need to be different. you have both objects with both the properties object. each property needs to be different You have

var objects = [
  {object: 13, object: 20 },
  {object: 10, object: 40},
  {object: 9,  object: 30 }
];

the second property in each object needs to be different. anything will do like this

var objects = [
  {object: 13, object2: 20 },
  {object: 10, object2: 40},
  {object: 9,  object2: 30 }
];

this is just an example. you can name your properties differently

Trent Stenoien
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Trent Stenoien
Full Stack JavaScript Techdegree Graduate 21,632 Points

Think of the exercise in terms of something in the real world and it'll be easier to understand how it works I think. Assign an object to your hometown then create a property for 'high school' and fill it with a string. Create a property for population and fill it with a number. Create a property for.....idk, movie theaters and fill it with an array of the different ones around town. Then repeat the process for the town next door.

var cities = [
{name: Minneapolis, state: MN, latitude: /*whatever it is*/, longitude: /*no idea*/},
{name: Chicago, state: IL, latitude: /*who knows*/, longitude: /*probably Google*/}
]

That's what worked for me anyway.