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 trialdan cheng
Full Stack JavaScript Techdegree Student 11,596 PointsI 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}];
var objects = [];
objects = [{name:'max',age: 24},{name:'matt',age: 24},{name:'dan',age: 24}];
<!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
12,755 PointsYou 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
dan cheng
Full Stack JavaScript Techdegree Student 11,596 Pointsdan cheng
Full Stack JavaScript Techdegree Student 11,596 Pointsgot it. thanks!