Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /************************************
- var number, str, ndigits;
- ndigits = 5; // you want it to have 5 digits
- number = 23; // this is your number
- str = digits(number, ndigits); // str == '00023' this is your result
- number = 936;
- ndigits = 10;
- str = digits(number, ndigits); // str == '0000000936'
- ************************************/
- function digits(n,ndigit){
- return (n.length < ndigit ? digits("0"+n, ndigit) : n);
- }
Advertisement
Add Comment
Please, Sign In to add comment