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

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.