I have:
while (i < l) {
if (one === two) { continue; }
i++;
}
But JSLint says:
Problem at line 1 char开发者_如何学Pythonacter 20: Unexpected 'continue'.
if (one === two) { continue; }
What mistake did I make? How should my code really look?
From the JSLint docs:
continue
StatementAvoid use of the continue statement. It tends to obscure the control flow of the function.
So take it out entirely if you want to conform to the conventions that JSLint follows.
What JSLint actually tries to say is to invert the if so you can eliminate the continue:
while (i < 1) {
if (one !== two) {
i += 1;
}
}
Furthermore, don't use "i++", but use "i+=1", if you want to stick to the strict guides of JSLint.
Hope this helps :)
精彩评论