Search code examples
javascriptsyntax-errorjslint

JSLint Character Unexpected '.'


Atoms's JSLint report is complaining about an unexpected dot of the .toFixed function:

subTotal = (Math.round(subTotal * 100) / 100).toFixed(2);

at line 113, character 50 Unexpected '.'

The code works fine,

Question: Is this a fault with JSLint or have I coded something wrong?

Thanks


Solution

  • jslint doesn't like the dot "." after a naked, parenthesized expression. adding a Number in front of ( should fix the warning. the other common-case is adding a String in front of (.

    subTotal = Number(Math.round(subTotal * 100) / 100).toFixed(2);