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

Justin Oswald
Justin Oswald
5,969 Points

I have tried various combinations answers and cant seem to find what its asking for

.

script.js
var objects = [
  name= {'Justin'}, 
  numbers= {4}, 
  answer= {true}
]
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

Austin Whipple
Austin Whipple
29,725 Points

In this challenge, there's no need to modify the HTML file, so there shouldn't be any issue there. In the JavaScript, however, you're asked to create an array of object literals that each contain to property/value pairs.

You're successfully creating your objects array. In addition, you're creating the objects in the array properly. However, you're not declaring your properties or assigning values. You'll need to create two properties for your name object. For instance, first: and last: name:

   name = {first:  , last:  }

This won't pass quite yet because you still need to assign values to these properties:

   name = {first: 'Justin', last: 'Oswald'}

And repeat for two other new objects in your array. For more information on working with objects can be found in the MDN.

Tim Strand
Tim Strand
22,458 Points

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. Step 1) declare the array literal (you have done this. dont forget the semicolon Step 2) create 3 object literals {} with 2 values apiece {key: value, key: value} (you havent done this)