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 trialRich Turnbull
9,212 PointsStuck on code challenge - (might be a bug)
Question is:
"Inside the array literal, add three object literals. In other words, the objects array should have three values. Each object should have 2 property/value pairs."
Here is my code for task 2 of the challenge however it's not passing? is this a bug or have i made a mistake?
var objects = [
{
name: 'John',
age: 17
}
{
name: 'Rich',
age: 21
}
{
name: 'James',
age: 33
}
];
var objects = [
{
name: 'John',
age: 17
}
{
name: 'Rich',
age: 21
}
{
name: 'James',
age: 33
}
];
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Objects</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
4 Answers
Colin Bell
29,679 PointsYou're forgetting the commas between your objects.
var objects = [
{
name: 'John',
age: 17
}, // Here
{
name: 'Rich',
age: 21
}, // Here
{
name: 'James',
age: 33
} // Not here since it's the last one.
];
Rich Turnbull
9,212 PointsAh okay - thanks Colin!
Layth Eshuwaili
12,128 PointsHi guys! what is wrong with my code? what i'm doing wrong here? thank you much.
var objects = [ { question: 'How many states in the United States'?, answer: 50 }, { question: 'How many legs the spider has'?, answer: 6 }, { question: 'How many tires the car has'?, answer: 4 } ];
mazarul islam
2,981 Pointshas'? the ' is before question mark. should be after. for all your object literals question mark is after the string value
Charlie Harcourt
8,046 PointsThere is an "?" outside of the quotes: 'How many states in the United States'?,
Hope this helps
:)
James Barshaw
9,284 Pointswhen using this answer this is the error that I get
Make sure you declare the objects
array with the var
keyword.
and I know the var keyword is objects so I don't know whats wrong