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

Charlotte Zhang
Charlotte Zhang
4,425 Points

Why it is telling me Task 1 is no longer passing?

Don't know why, I tried at least five times, it just keep telling me task one (creating a literal array named coordinates) is no longer passing, did I do something wrong?

script.js
var coordinates = [
[thing1, thing2]
];
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

You were asked to create an empty two-dimensional array, however, you added "thing1" and "thing2" to it and since it is not empty, it will not pass.

Here is how to create an empty two-dimensional array

var coordinates = [[],[]];
Charlotte Zhang
Charlotte Zhang
4,425 Points

That's not the issue, but never mind, I fixed it, I failed to put "" around a string. Thanks for the quick response!

If your issue was with task two, you can just add the elements to the array like this

var coordinates = [[],[]];
coordinates[0][0] = 'thing1';
coordinates[0][1] = 'thing2';

instead of directly adding it to the array like what you did above

var coordinates = [
[thing1, thing2]
];
Steven Parker
Steven Parker
229,745 Points

Congratulations on resolving your issue. :+1:

But to answer your original question, the challenge always re-tests the previous tasks in order. And if you've introduced a syntax error (such as the reference to non-existent variables), that will invalidate the whole script. So the tester will report that as "Task 1 is no longer passing".