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

Timothy Harrington Bourne
Timothy Harrington Bourne
6,372 Points

GRRR WHAT IS WRONG?????

Sseriously what is wrong with my code?? this is so annoying >.<

i've tried everything i could, but it still says bummer!

script.js
var objects = [
  {
   name:'tim',
   sex: 'male',
   maritalStatus: true,
  },
  {
   name:'tim',
   sex: 'male',
   maritalStatus: true,
  },  
  {
   name:'tim',
   sex: 'male',
   maritalStatus: true
  }
]
index.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JavaScript Objects</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>

4 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi Timothy,

When doing challenges on Treehouse, the instructions must be followed exactly or you will get the Bummer! even with syntactically correct code.

Here the instruction explicitly state that: "Each object should have 2 property/value pairs. Yours have 3. In fact, when checking your code, you receive the error message that says: "Bummer! Each object must have two properties."

So, if you just delete one of the properties you have inside the object literals, the rest of your code is correct, and the challenge will pass.

Just a note: your commas are correct, and it doesn't matter if there is a semicolon or not after the closing square bracket. The convention for semicolons in JavaScript is a highly debated topic right now, and while putting one there is still the more common convention, leaving it out is completely fine too. Semicolons in JavaScript are statement separators not statement enders, so it's really up to you... just be consistent.

Nice work!! :) :dizzy:

Remove the commas after assigning the maritalStatus value.

Timothy Harrington Bourne
Timothy Harrington Bourne
6,372 Points

commas are needed all the way up to the last maritalStatus because its the continuation of the previous objects, and also the semicolons dont really affect the code since I did the previous challenges with no semicolons at all.. I tried all of this before posting this question and it didnt work

And put a semi-colon after the square bracket on the last line.