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 trialRebecca Collins
Courses Plus Student 3,871 PointsArray of objects
I am trying to create an array with objects inside of it. I tried the code below and it's giving me a parse error... stack overflow is suggesting I use the array.push() method but this is the example I was given in Treehouse for how to initialize them together. Any suggestions?
var objects =[ { letter: 'a';, number: 1; }, { letter: 'b';, number: 2; }, { letter: 'c';, number: 3; }
];
var objects =[
{
letter: 'a';,
number: 1;
},
{
letter: 'b';,
number: 2;
},
{
letter: 'c';,
number: 3;
}
];
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Objects</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
1 Answer
Steven Parker
231,236 PointsThe error is caused by the semicolon characters inside the objects, which are not part of object syntax.
Remove the semicolons (except for the one at the end of the assignment) and you will pass the challenge.
Rebecca Collins
Courses Plus Student 3,871 PointsRebecca Collins
Courses Plus Student 3,871 PointsAHH! Thank you so much, It's always something simple! haha