Back
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?
To round of till 2 decimal places, you can use the following piece of code:-
Math.round(num * 100) / 100
If you are passionate to pursue a career in Web Development, you can take up Web Development Online Courses by Intellipaat!
31k questions
32.8k answers
501 comments
693 users