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 trialBrain Station
3,849 PointsObjects, Inside An Array Challenge - Why?
js
var objects = [
var obj1 = {
name: "matt",
age: 25
},
var obj2 = {
name: "fareed",
age: 20
},
var obj3 = {
name: "melinda",
age: 21
}
];
Error: "Looks like step one, is no longer working." Step one: was simple to creat an array literal with nothing in it (named to objects). But, when I attempt to put my 3 objects (with two property/value pairs each) inside the array... it wont work. Help please?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Objects</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
3 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHey there,
You're on the right track, except you don't assign variable names to the object in a key: value
pair. Other than that you're syntax is correct.
var objects = [
{
name: "matt",
age: 25
},
{
name: "fareed",
age: 20
},
{
name: "melinda",
age: 21
}
];
Keep Coding!
Tushar Singh
Courses Plus Student 8,692 PointsIt's a very minor mistake. Why are you creating variables "var" inside an array.
array =[1, 2, 3] that's it no var.
var objects = [
obj1 = {
name: "matt",
age: 25
},
obj2 = {
name: "fareed",
age: 20
},
obj3 = {
name: "melinda",
age: 21
}
];
Brain Station
3,849 PointsThanks for your answer Tushar!
Tushar Singh
Courses Plus Student 8,692 PointsAnytime, I did the same mistake when I was working on this challenge
Tyler Durden
2,406 PointsI was getting a parse error until I named my array "var objects". That's kind of dumb because it was never explicitly stated to call the array that, although it was hinted imo.
Brain Station
3,849 PointsBrain Station
3,849 PointsThanks Jason so, it essentially comes down to a syntax error?
Jason Anders
Treehouse Moderator 145,860 PointsJason Anders
Treehouse Moderator 145,860 PointsYep.
The "Task one is no longer passing" is very misleading. It will always be something done in the current Task and never actually related to the first task. So, when you encounter this, don't click "Go back to task one." Just look carefully at your code (specifically any code changed and / or added since the last Task) for any syntax errors. Often it's as simple as a missing semi-colon. I've been in a challenge and on Task 3 or 4... missed a semi-colon and got the "Task one" error.
:)