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"