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

Jason Widjaja
Jason Widjaja
7,904 Points

how do i do the last part here?

i dk how to add 3 more arrays

script.js

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

Hi here is a detailed solution:

//First, create coordinates variable
let coordinates = [];
//Second, add one array to the array
coordinates.push([8,9]); 
//Third, add three more items to the array

Either you repeat 3 times the push method like we did earlier or you do it in a DRYER WAY!
for(let i = 0;i < 3;i++){
      coordinates.push([3,3]);
}

If that helped you, please mark as best answer to indicates other student your issue is resolved!

Steven Parker
Steven Parker
229,732 Points

Be aware that there are multiple ways to solve this challenge, this might not be the approach you would use solving it yourself. Also, this code contains an error and is not a valid solution as-is.
UPDATE: the error has been fixed.

Fran ADP
Fran ADP
6,304 Points

create a coordinate.