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 trial

JavaScript JavaScript Loops, Arrays and Objects Tracking Data Using Objects Create an Array of Objects

james mchugh
james mchugh
6,234 Points

Syntax error

I'm really not sure what I'm suppose to do here

script.js
var objects = [
  {
"name":"Joe",
"age":19,
"city":"LA"
  }
  ];
























['cities', NY, LA]
];
index.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JavaScript Objects</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>

2 Answers

You seem to have code right at the bottom of your work space that doesn't look very necessary? Try taking away that code and if not try something like this code below BUT NOT THIS DON'T COPY :D

var objects = [

{

"animal":"Dog",

"breed":Boston

}

];

:)

Yes just tried out your code without that stuff at the bottom and it works fine. Did you forget to remove it? :P

james mchugh
james mchugh
6,234 Points

Yeah I',m not sure why that is there. I think it's from an earlier attempt and it never got deleted. I posted a new attempt , but I'm getting a syntax error message.

John Lack-Wilson
John Lack-Wilson
8,181 Points

Hi James, did you manage to resolve this?

If not, here's what looks to be going wrong:

  • Theres a stray '];' at the very end of the js file
  • NY and LA are not in quotes, and thus will be treated as variables, so you should either define them as variables or put quotes around them