Skip to content Skip to sidebar Skip to footer

Unexpected 'continue'

I have: while (i < l) { if (one === two) { continue; } i++; } But JSLint says: Problem at line 1 character 20: Unexpected 'continue'. if (one === two) { continue; } Wh

Solution 1:

From the JSLint docs:

continue Statement

Avoid 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.

Solution 2:

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 :)

Post a Comment for "Unexpected 'continue'"