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 trialRapha Montenegro
1,986 PointsWhy is it not recognizing the second property?
I can't find the problem in my code to why the text editor doesn't recognize "age" as a property.
var objects = [
{
name = "Rapha",
age = 29
}
{
name = "Rosana",
age = 28
}
]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Objects</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
3 Answers
Charlie Harcourt
8,046 PointsYou're forgetting the commas between your objects. Also you need to change equals to ':' this should do it :)
var objects = [ {
name: 'Charlie',
age: 17
}, // Here
{
name: 'Ben',
age: 21
}, // Here
{ name: 'James', age: 33
} // Not here since it's the last one.
];
Yuval Blass
18,134 PointsHi there ?,
- JS object literal is a comma-separated list of name-value pairs with colons (:), not equals sign (=).
- You need to separate the items inside the array with commas (,).
- You need to create 3 objects inside the array, not only two.
Have a good luck!
? Yuval ?
Rapha Montenegro
1,986 PointsHi Yuval! Thanks for the heads-up with the (:) in place of (=) Now I have a new issue. The third object isn't being recognized. My code is like this:
var objects = [ { name: "Rapha", age: 29, } { name: "Rosana", age: 28 } { name: "Greta", age: 4 } ]
Rapha Montenegro
1,986 PointsJust found the issue! Thanks!!
Yuval Blass
18,134 PointsI'm glad I could help. ?
Have a nice day! ?