I have a series of numbers. For example:
3, 3.4567, 4.5, 5.72, 6.12345
How can I show original numbers if they are integers or they have no more than 3 digits after the decimal point and show max 3 digits after the decimal point if there are more than 3? Here is what I want:
3, 3.456, 4.5, 5.72, 6.123
I used toFixed(), but it makes each number come with 3 digits after the decimal point.
Is there any Javascript method to use to achieve what I want?
--------- update -----------
I used this from the pointer:
Math.round(original*1000)/1000
from the old post. It seems working.