我正確地認爲,如果第一個if語句和嵌套,如果在else語句中都失敗了,我然後回到第一個for循環,並且遞增i
1?其他語句嵌套if
所以我可以繼續直到j < totalCols失敗,即使if或else語句都沒有執行?
var rowCount = [];
for (var i = 0; i < totalRows; i++) {
rowCount[i]="";
spaceCount = 0;
for (var j = 0; j < totalCols; j++) {
if (puzzle[i][j] == "#") { // if this fails?
spaceCount++;
if (j == totalCols-1) rowCount[i] += spaceCount + " ";
} else {
if (spaceCount > 0) { //and this fails?
rowCount[i] += spaceCount + " ";
spaceCount = 0;
}
}
}
}
所以我可以繼續下去,直到j
KMcA