Javascript dois dígitos Número
var myNumber = 7;
var formattedNumber = ("0" + myNumber).slice(-2);
console.log(formattedNumber);
Doubtful Deer
var myNumber = 7;
var formattedNumber = ("0" + myNumber).slice(-2);
console.log(formattedNumber);
function n(num, len = 2) {
return `${num}`.padStart(len, '0');
}
console.log(n( 9)); //print "09"
console.log(n(10)); //print "10"
console.log(n(999)); //print "999"
console.log(n(999,6));//print "000999"