ajya ajya - 2 months ago 11
Javascript Question

How to do two decimal places roundup in java script

input:

11
2.7777777
8.1


Output:

11
2.78
8.1


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

How can I do this in JavaScript?

Answer

Use Math.round(num * 100) / 100

Comments