I'm aware that the way to truncate a number to 2 decimal places in toFixed()
. However, in case the number has just 1 decimal place, I get an error.
What is the way to mandate a number to display >2 decimal places(numbers after the decimals will be 0 in this case) so that toFixed()
will not throw an error?