Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js pad 2

function pad2(n) {
  return (n < 10 ? '0' : '') + n; 
}
alert(pad2(3)); //03
alert(pad2(12)); //12
 
PREVIOUS NEXT
Tagged: #js #pad
ADD COMMENT
Topic
Name
2+6 =