Question about toFixed() method

Hi campers,

Could you please point me out why this 10.toFixed(2) is an error, while this 10..toFixed(2) is OK.

Thank you!

For the same reason that (10).toFixed(2) works.

See this StackOverflow explanation.

On a side note, if you already have a known number you want to convert to a fixed point string, you would not even need to use toFixed. Instead, you would just write out 10.00.

1 Like

Thank you very much!