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

Add three more arrays to the coordinates array. The coordinates array should have 4 arrays in it -- each of those arrays

Add three more arrays to the coordinates array. The coordinates array should have 4 arrays in it -- each of those arrays should have 2 items in it. i'm stuck with this challenge task 3 of 3 pliz help

script.js
coordinates.push = [
[John,David],
[Joe, Beckham],
[Messi, Ronaldo],
[Solomon,C.Ronaldo],
];
index.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JavaScript Objects</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>

3 Answers

Neil McPartlin
Neil McPartlin
14,662 Points

This post is linked to a 3 step challenge where they only want you to create a 2 dimensional array. There is no 'push' involvement in the challenge. I don't know how you answered the first 2 challenges. But this would work.

Challenge 1:

var coordinates = [];

Challenge 2:

var coordinates = [
  ['John', 'David']
];

Challenge 3:

var coordinates = [
  ['John', 'David'],
  ['Joe', 'Beckham'],
  ['Messi', 'Ronaldo'],
  ['Solomon', 'C.Ronaldo']
];
Valeshan Naidoo
Valeshan Naidoo
27,008 Points

very close, push is a method, so you enclose the value(s) in parentheses, push(). Also you don't have to equate it, you just use it like this, coordinates.push([1,2],[3,4],[5,6])

Yim Ming Chu
Yim Ming Chu
1,797 Points

As you already added on array, you just need to use coordinates.push to add 3 more arrays each with 2 items, making a total of 4 arrays.