Jslint is returning an odd error to a very annoying section of code I've copied from my textbook. Here is how the code was in the book:
....
{
for(var column = 0; column < COLUMNS; column++)
{
var currentTile = levelMap[row][column];
if(currentTile !== EMPTY)
and that threw up a bunch of errors, like you cant assign a value of 0 to undefined or whatever. so i switched the var statements around like this...
{var row = 0;
var column=0;
for(row < ROWS; row++;)
{
for( column < COLUMNS; column++;)
{
var currentTile = levelMap[row][column];
if(currentTile !== EMPTY)
{
so having it this way- it works now. (sort of...chrome doesnt throw up bugs but its not working well. things are not displaying in my game) but if i run it through jslint i get this error.
Unexpected ')'.
for(row < ROWS; row++;)
taking the ; off of row++ breaks it. taking the ) out breaks it.
And even though it runs, it doesn't run right. I can provide more information if you'd like, thought i'd just keep it on the shorter end .
im an idiot, apparently, cause i cant figure it out.
A for loop consists of four pieces of information:
*actually those are all expressions, but it's more important to remember what they're for
for(init; cond; post)
statement;
it can be directly translated into a while loop, if you feel more comfortable using that one:
init;
while(cond){
statement;
post;
}
As you can see, you we're missing the init. Note that all of the four can be empty. Overall we get:
var row, column, currentTile;
for(row = 0; row < ROWS; row++) {
for(column = 0; column < COLUMNS; column++) {
currentTile = levelMap[row][column];
if(currentTile !== EMPTY) {
// ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With