1const number = 5;
2console.log(number.toString().padStart(2, '0')); // expected output: "05"
1function padLeadingZeros(num, size) {
2 var s = num+"";
3 while (s.length < size) s = "0" + s;
4 return s;
5}
6padLeadingZeros(57, 3);// "057"
7padLeadingZeros(57, 4); //"0057"