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

cody ainsworth
cody ainsworth
3,769 Points

Objects Inside of arrays

I keep getting a parse error and I truly do not understand what is wrong with the code

script.js
Var object = [
     //Object 1
    {one: "one1",
     two: "two2"
    },
      //Object 2
     {Key1: "value1",
        Key2: "value2"
     },
   //Object 3
    {Something: "Victor2",
     Something2: "Victor3"
    }
]
index.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JavaScript Objects</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>

1 Answer

A couple things need correcting.

  1. Var should be var.
  2. You're missing the s in object(s).
var objects = [
     //Object 1
    {one: "one1",
     two: "two2"
    },
      //Object 2
     {Key1: "value1",
        Key2: "value2"
     },
   //Object 3
    {Something: "Victor2",
     Something2: "Victor3"
    }
]