?
Solved

JavaScript Error: Unexpected Token

Posted on 2016-09-24
2
Medium Priority
?
157 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Assisted Solution

by:Jeffrey Dake
Jeffrey Dake earned 1200 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 800 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…
Suggested Courses

765 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