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

Array Object

Challenge Task 2 of 2

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. Important: The code you write in each task should be added to the code written in the previous task

so am i supposed to add strings?

script.js
var objects = [
'objects'

]
index.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JavaScript Objects</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>

Hi Andrew, Inside the array literal, place 3 object literals. So, going off of what is in your scripts.js:

var objects = [ {question: "red + yellow", answer: "orange" }

]

I added one object literal. This array literal just needs two more. This is my first answer, so I am still figuring out the syntax.

2 Answers

An object literal is not a string, but another data type that looks like this: { propertyName: propertyValue } So if you add three of these objects with two properties then you should be good!

To read about object literals go here.

Hi Andrew, I am adding in one object literal to your array:

var objects = [
  {question: "blue + yellow",
   answer: "green"
  },

add two more object literals here

]

The object literal above has the 2 property/value pairs (question and answer).