From 689f3ff4a16dec987e5ffb8d67c3184133bbc5e2 Mon Sep 17 00:00:00 2001 From: Josh Creek Date: Mon, 26 Oct 2020 16:12:09 +0000 Subject: [PATCH] fix(*): Padd generated code with leading zeros --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index d550d6a..ae002fc 100644 --- a/index.js +++ b/index.js @@ -53,7 +53,8 @@ function generateRandomCode() { const num1 = Math.floor((Math.random() * 9999) + 1); const num2 = Math.floor((Math.random() * 9999) + 1); - return `${num1}-${num2}`; + // Pad the start of the numbers so there's always four digits, including leading zeros + return `${num1.toString().padStart(4, '0')}-${num2.toString().padStart(4, '0')}`; } function checkQueue(message) {