From 61e847453620206e1309b8973b3275065fba212a Mon Sep 17 00:00:00 2001 From: Ayoub-Mabrouk Date: Wed, 6 Nov 2024 02:09:19 +0100 Subject: [PATCH] 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. --- scripts/version-history.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/scripts/version-history.js b/scripts/version-history.js index b8a2b0e..daf631a 100644 --- a/scripts/version-history.js +++ b/scripts/version-history.js @@ -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'); }