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 trialJordan Green
6,363 PointsWhen I fill the array literal with object literals the arrays no longer pass the first test. What's wrong here?
I used the following code to pass the second part of this question only to be confronted with the problem that the object literals do not cause the array literal not to pass. The instructions say that I should put the objects inside of the array. What am I missing? Is my code off? Am I not formatting the objects correctly? Any insight would be greatly appreciated.
var objects = [ var object1 = {love: 50, loss: 25}, var object2 = {health: "Nope", health2: 34}, var object3 = {demon: [12, 14, 13, 2], demongate: venus}, ];
Thanks
var objects = [
];
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Objects</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
5 Answers
Seth Kroger
56,413 PointsYou don't need the "var objectn =" part inside the array brackets, and you have an extra comma after the last object. Also in the last object you have "demongate: venus" that will look for a variable named venus you haven't declared yet.
Unsubscribed User
8,841 PointsHi,
the expected solution is like the below one. You have added an equal to sign which wont be required. And few syntax errors. Can you go through the video again and try the challenge again.
var objects = [ {ques:'aa',
ans:'bb'} ,
{ques:'cc',
ans:'dd'} ,
{ques:'ee',
ans:'ff'} ];
Jordan Green
6,363 PointsThanks Aishu!
Jordan Green
6,363 PointsThanks Aishu!
Luksy Breezy
268 Pointsvar objects = [
{
"firstName":"John",
"lastName":"Doe"
},
{
"age":24,
"sex":"M"
},
{
"petName":"Fido",
"school":"Treehouse"
}
];
Jordan Green
6,363 PointsThanks Luksy!
Luksy Breezy
268 Pointsur welcome bro
Jordan Green
6,363 PointsJordan Green
6,363 PointsThanks Seth, I'll try these suggestions.