Function to round of the decimal value is shown below.
//Example to fix a decimal value to 2 decimal places when it has number of decimal places
var num = 234.8766;
var result = num.toFixed(2); //The result will be 234.88;
//to fix to a 2 decimal values if a number has no decimal values
var num = 8769;
var result = num.toFixed(2); //The result will be 8769.00;
No comments:
Post a Comment