Skip to content

Commit 61e8474

Browse files
committed
Refactor zeroPad to use padStart for improved readability
Replaced the manual loop with `padStart` to simplify the code and improve readability. This aligns with modern JavaScript practices, making the function more concise and easier to maintain. No functional changesjust a cleaner, more efficient approach to padding numbers with leading zeros.
1 parent 87c5f09 commit 61e8474

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

scripts/version-history.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ function repeat (str, length) {
5252
return out
5353
}
5454

55-
function zeroPad (number, length) {
56-
var num = number.toString()
57-
58-
while (num.length < length) {
59-
num = '0' + num
60-
}
61-
62-
return num
55+
function zeroPad(number, length) {
56+
return number.toString().padStart(length, '0');
6357
}

0 commit comments

Comments
 (0)