In my code I will be accepting multiple values, for example:
8.7456
8.7
8
and I need to have them appear as
8.74
8.7
8
i.e. display up to two decimal place.
I understand that .toFixed(2)
will help me with the first value, but on the 2nd and 3rd value there will be trailing zeroes that I do not want.
How to produce my desired results?