Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Loops, Arrays and Objects Tracking Multiple Items with Arrays Create a Two Dimensional Array

Jordan Leithner
Jordan Leithner
1,045 Points

Unexpected token ILLEGAL when creating two dimensional arrays

When doing the code challenge, I was to create an array within an array but got the error message "Unexpected token ILLEGAL on line 5". (Line 5 is the line with [007, 008]).

I'm wondering what is the "illegal token" on line 5 of my code? Am I missing something?

script.js
var coordinates = [
  [001, 002],
  [003, 004],
  [005, 006],
  [007, 008]
];
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

I'm not sure about the token myself but I think the error has to do with the leading zeroes. I enclosed all of your values in quotes and that passed the challenge.

Cheo R
Cheo R
37,150 Points

Integer literal beginning with 0 is interpreted as an octal (base 8) quantity.

For single-digit numbers (other than 08 and 09, which are not allowed) they print the same, 008 causes error. So all you need to do is to change the last element in the last sublist.