How to round to at most 2 decimal places, if necessary?
Asked 07 September, 2021
Viewed 2.9K times
  • 71
Votes

I'd like to round at most 2 decimal places, but only if necessary.

Input:

10
1.7777777
9.1

Output:

10
1.78
9.1

How can I do this in JavaScript?

30 Answer