Q:

Use .toFixed() to only show 3 decimal when required

How can I use .toFixed() to this result.
number     display
------     -------
1          1
1.23       1.23
1.23456    1.235

I have been using .toFixed(3). But it's display.
number     display
------     -------
1          1.000
1.23       1.230
1.23456    1.235

A:

You can try to use:
Math.round(yournum * 1000) / 1000

or you can try:
+(Math.round(num + "e+3")  + "e-3")

