How TO - Format a Number with Two Decimals
Learn how to format a number with two decimals in JavaScript.
Format a Number with Two Decimals
You can use the toFixed()
method to format a
number to only show two decimals. Note that the result is rounded (shows 5.57 instead of 5.56):
If you want to display three decimals, just change the number to 3:
Tip: Learn more about the toFixed() method in our JavaScript Reference.
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.