Solved

JavaScript Error: Unexpected Token

Posted on 2016-09-24
2
71 Views
Last Modified: 2016-09-25
I am  working on a exercise(End of Chapter 2) in the "Eloquent JavaScript" book.

I am trying to build a chessboard but I am getting an error, "Unexpected Token".

http://codepen.io/isogunro/pen/dpvKJp?editors=1012

Any help would be appreciated.

Thanks!
0
Comment
Question by:Isaac
2 Comments
 
LVL 10

Assisted Solution

by:Jeffrey Dake
Jeffrey Dake earned 300 total points
ID: 41814259
On the third line you don't have x set to anything.   Unexpected token is JavaScripts way of telling you that you have incorrect syntax.
0
 
LVL 22

Accepted Solution

by:
Kim Walker earned 200 total points
ID: 41814280
Jeffrey Dake is correct about the error on line 3.

More specifically, unexpected token simply means that a token appeared where something else was expected. A token in javascript is a punctuation character or operator. There are several tokens in the third line of your javascript -- the parentheses, the equals operator, the semi-colons, the less-than-or-equal-to operator (<=), the positive increment operator (++), and the left curly brace. In this case, the parser was expecting a value for the equals operator but instead encountered the semi-colon statement terminator. So the semi-colon token was unexpected.
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question