[Solved] Lint warnings: leading zeroes and increment/decrement operators


In many languages, a number with a leading zero is considered to be a octal (i.e. base 8) literal, apart from 0 itself. For example 012 is the decimal number ten, even though it looks more like twelve. So 00 is considered to be an octal number, although it’s obviously zero.

Octal literals are however a syntax error in strict mode, as octal numbers were never part of the ECMAScript standard. I imagine your linter is enforcing the same rule.

So the fix to your first problem is simple:

    case "99" : myCount = 0;   // Drop one of the zeroes.

The second problem is here:

while(_length--){

You are decrementing the value of length and also reading either its original or new value. Your linter is complaining because you are doing both. Doing so makes for code that is difficult to read. In particular, does the loop run length times or length - 1 times? It’s not clear.

Your while loop always runs a fixed number of times, so from a stylistic point of view you would be better off with a for loop:

for (var i = 0; i < length; ++i) {
    _retString += _charSet.charAt(Random(0, _charSet.length-1));
    Delay(1);
}

As you’re now only using ++ in the ++i statement within the for loop, this should avoid lint warnings.

6

solved Lint warnings: leading zeroes and increment/decrement operators