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

Two Dimensional Array

Task 1 of an assignment was:"In this code challenge you need to create a two-dimensional array -- an array of arrays. Start by creating an empty array literal named coordinates."

I got that right by saying: var coordinates = [];

This question i'm stuck on is Task 2 https://teamtreehouse.com/library/javascript-loops-arrays-and-objects/tracking-multiple-items-with-arrays/create-a-two-dimensional-array

A two-dimensional Array is an array of arrays. Add 1 array to the coordinates array. That new array should have two items in it.

I thought it would be: var coordinates=[ [dog,cat] ];

But, when I type that in it tells me that Task 1 is no longer passing, what am I doing wrong?

1 Answer

Steven Parker
Steven Parker
243,318 Points

You're probably getting a syntax error because dog and cat are not defined. Try using literals for the elements:

var coordinates = [ ["dog", "cat"] ];