Skip to content

Commit

Permalink
Refactor zeroPad to use padStart for improved readability
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Ayoub-Mabrouk committed Nov 6, 2024
1 parent 87c5f09 commit 61e8474
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions scripts/version-history.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ function repeat (str, length) {
return out
}

function zeroPad (number, length) {
var num = number.toString()

while (num.length < length) {
num = '0' + num
}

return num
function zeroPad(number, length) {
return number.toString().padStart(length, '0');
}

0 comments on commit 61e8474

Please sign in to comment.