Contact: aviboots(AT)netvision.net.il
39,895 questions
51,826 answers
573 users
let n = 34891; // padStart(targetLength, padString) console.log(String(n).padStart(8, '0')); /* run: 00034891 */
function LeftPadWithChar(n, len, padch = '0') { n = n + ''; return n.length >= len ? n : new Array(len - n.length + 1).join(padch) + n; } let num = 34891; console.log(LeftPadWithChar(num , 8)); /* run: 00034891 */