I simplified my program to this and it is still wrong:
var grid = [0, 1, 2, 3]; function moveUp(moveDir) { for (var row in grid) { console.log('row:'); console.log(row + 5); } }
It seems that row is a string instead of an integer, e.g. output
row: 05 row: 15 row: 25 row: 35
not 5, 6, 7, 8, which is what I want. Shouldn't the counter in a for loop be a string?
javascript string for-loop
stackers
source share