Answers for "add zeros at the end to a number in js"

4

add leading zeros to number javascript

const number = 5;
console.log(number.toString().padStart(2, '0')); // expected output: "05"
Posted by: Guest on August-12-2021
0

add leading zeros javascript

function pad(num, size) {
    num = num.toString();
    while (num.length < size) num = "0" + num;
    return num;
}
Posted by: Guest on April-02-2022

Code answers related to "add zeros at the end to a number in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language