0 votes
1 view
in Web Technology by (47.8k points)

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?

1 Answer

0 votes
by (107k points)

To round of till 2 decimal places, you can use the following piece of code:-

Math.round(num * 100) / 100

Related questions

0 votes
1 answer
0 votes
1 answer
asked Jul 9, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
asked Oct 17, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
asked Oct 9, 2019 in Java by Anvi (10.2k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...