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

dan cheng
seal-mask
.a{fill-rule:evenodd;}techdegree
dan cheng
Full Stack JavaScript Techdegree Student 11,596 Points

I dont why it keeps saying task 1 is not passing.

var objects = []; objects = [{name:'max',age: 24},{name:'matt',age: 24},{name:'dan',age: 24}];

script.js
var objects = [];
objects = [{name'max',age: 24},{name'matt',age: 24},{name'dan',age: 24}];
index.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JavaScript Objects</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>

1 Answer

Caleb Kemp
Caleb Kemp
12,755 Points

You already initialized the array objects, therefore to change it's size, you have to push to it. so essentially, if you change your code from

objects = [{name:'max',age: 24},{name:'matt',age: 24},{name:'dan',age: 24}];

to

objects.push({name:'max',age: 24},{name:'matt',age: 24},{name:'dan',age: 24});

your code will work