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 Multiple Items with Arrays Create a Two Dimensional Array

Pleasure help me

I don't have idea

script.js
var coordinates = [ [1,2], [2,3], [3,4], [9,10] ];
coordinates.push([12, 20]);
coordinates.push([1,2],[3,4],[5,6])
var coordinates = [ '[2,3] [3,1]  [5,10]' ];
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

Thanks a lot

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 28,720 Points

It looks like you have studied some JavaScript syntax-- let's work with that. I will use the parts of your code which were working in isolation.

Let's solve EACH part of the challenge below-- I copied in-place your code ;-)

part 1 - declare an empty array named coordinates. A possible solution is below.

var coordinates = [];  // this is just a declaration of an empty array.

part 2 - add on an array of 2 elements to coordinates. A possible solution is below. Notice the second line from your code, is used with an empty array declared on the first line called coordinates.

var coordinates = []; // this is just a declaration of an empty array.
coordinates.push([12,20]); // this adds a new item to the coordinates array.

part 3 - make the array hold 4 sets of coordinates. You can just use your first line as a "declarative approach." This is a possible solution that will work. I copied the first line of your solution in to show you that it works on its own!

var coordinates = [ [1,2], [2,3], [3,4], [9,10] ]; // this works as a declarative approach to solving the challenge.

part 3 - Alternative "builder" approach

var coordinates = []; // this is just a declaration of an empty array.
coordinates.push([1, 2]); // push on a first element
coordinates.push([2, 3]); // push on a second
coordinates.push([3, 4]); // push on a third
coordinates.push([9, 10]); // push on a fourth