tags:

views:

34

answers:

1

What's wrong with this code?

var result = 985.toFixed(2);

And the fix is:

var result = (985).toFixed(2);

I still want to know the reason. :)

+5  A: 

In the first example, the Javascript interpreter interprets the dot as a decimal point, because it's coming after a number.

Putting brackets around the number gets around this limitation.

thomasrutter