Reputation: 3964
I have a for loop, but in one condition, I want to skip some steps so that I have used goto
statement...
for (var rows = 0; rows < result.data.length; rows++) {
[lbl] topOfLoop:
var row = result.data[rows]
if (row[0] == "") {
goto topOfLoop;
}
----- // some code
}
Its not working ? Can anyone tell me, how it could be done ?
Upvotes: 0
Views: 20515
Reputation: 47127
Pretty sure you want to use continue;
:
for (var rows = 0; rows < result.data.length; rows++) {
var row = result.data[rows];
if (row[0] == "") {
continue;
}
// some code
}
Upvotes: 4
Reputation: 98868
Use continue
statement in your code;
The continue statement passes control to the next iteration of the enclosing iteration statement in which it appears.
It is one of the Jump statements.
if (row[0] == "")
{
continue;
}
Upvotes: 1