javascript add leading zero to single digit number code example
Example 1: javascript print int with leading zeros
function padLeadingZeros(num, size) {
var s = num+"";
while (s.length < size) s = "0" + s;
return s;
}
padLeadingZeros(57, 3);// "057"
padLeadingZeros(57, 4); //"0057"
Example 2: add zero in front of numbers lower than 10 python
print(f"{x:02}") # where x is the integer