Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!