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

Adewuyi Kupolati
PLUS
Adewuyi Kupolati
Courses Plus Student 8,887 Points

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

I can't answer my question. I need help please. Thank you.

script.js
var objects = [
  {month: 'June', answer: LGBT},
  {month: 'September', answer: Birth},
  {month: 'February', answer: Pisces}

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

4 Answers

Hi Adewuyi,

The reason why you're getting an error is because the 2nd property in each of your objects isn't encapsulated by a set of quotes. Each of those values should be strings surrounded by single or double quotes :)

//I added single quotes to each value
//but you can use either single or double quotes for each value
var objects = [
  {month: 'June', answer: 'LGBT'},
  {month: 'September', answer: 'Birth'},
  {month: 'February', answer: 'Pisces'}
];

Strings have to go inside quotes. SO, you are looking for:

var objects = [
  {month: 'June', answer: 'LGBT'},
  {month: 'September', answer: 'Birth'},
  {month: 'February', answer: 'Pisces'}
];

You got it right! You're welcome, and happy coding! =]

Barry Barnes
Barry Barnes
18,631 Points

n00b!!! Just kidding, I needed help too :)

Thanks!