From 8169715d72d152446d429686a1679ce9504c821b Mon Sep 17 00:00:00 2001 From: Alexander Zaytsev Date: Sat, 4 May 2024 18:39:58 +0300 Subject: [PATCH] Update index.js --- index.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 4a9318e..fce55bb 100644 --- a/index.js +++ b/index.js @@ -16,17 +16,12 @@ const increment = (acc, index, start, end) => { if (acc.length === index) { acc.push(0); - return; - } - - if (acc[index] < start) { + } else if (acc[index] < start) { ++acc[index]; - return; + } else { + acc[index] = 0; + increment(acc, ++index, end, end); } - - acc[index] = 0; - - return increment(acc, ++index, end, end); }; /**