Created
March 10, 2020 05:28
-
-
Save rashid327/14122d2c72ca998d7245d77b20bbae29 to your computer and use it in GitHub Desktop.
Round value in JavaScript upto 6 decimal places
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var val = 21.877768666 | |
Math.round(val * 1000000) / 1000000); | |
Output: | |
21.877769 |
var val = 21.877768666
Math.round(val * 1000) / 1000);
Output:
21.878
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
var val = 21.877768666
Math.round(val * 100) / 100);
Output:
21.88