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 trialJordan Leithner
1,045 PointsUnexpected 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?
var coordinates = [
[001, 002],
[003, 004],
[005, 006],
[007, 008]
];
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Objects</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
2 Answers
KRIS NIKOLAISEN
54,971 PointsI'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
37,150 PointsInteger 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.
Jordan Leithner
1,045 PointsJordan Leithner
1,045 PointsAhh ok, thank you!!