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 trialRiya Chatterjee
7,582 PointsHelp with two-dimensional arrays
I was working on the coding challenge 'Create a two-dimensional array' when I ran into some trouble. I had had already completed tasks 1 and 2 out of 3, but I couldn't manage to pass Task 3. Here is my code:
var coordinates = [
[2, 3]
[2, 12]
[7, 10]
[4, 5]
];
It says 'Oops! It looks like Task 1 is no longer passing.' Here are the tasks:
- Task 1 - 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.
- Task 2 - 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.
- Task 3 - 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.
Please help, Thank you.
5 Answers
Kevin Faust
15,353 PointsLooks like your only problem is that you forgot to put commas between each array
Ali Al Hudari
9,876 Pointsvar coordinates = [ [1,2], [2,3], [3,4], [9,10] ];
Tom Nguyen
33,500 Pointssolution:
var coordinates = [
[2, 3],
[2, 12],
[7, 10]
];
Leslio McKeown
Python Development Techdegree Student 9,439 PointsYou forgot to add the commas after each of your arrays
EX: var coordinates = [ [2,3], [4,9], [6,8] ];
Starky Paulino
Front End Web Development Techdegree Student 6,398 Pointscoordinates.push([1,2],[3,4],[5,6])