Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get Two digit number js

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"
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Two #digit #number #js
ADD COMMENT
Topic
Name
1+2 =