js number two digits code example
Example 1: javascript round to 2 digits
var num = 2;
var roundedString = num.toFixed(2);// 2.00
Example 2: js number with four decimal places
var myNumber = 2;
myNumber.toFixed(2); //returns "2.00"
myNumber.toFixed(1); //returns "2.0"
Example 3: javascript two character integer
var myNumber = 7;
var formattedNumber = ("0" + myNumber).slice(-2);
console.log(formattedNumber);