From cc28cffb192c5d4c173c89686900cb01a738da51 Mon Sep 17 00:00:00 2001 From: woodgas <110297758+woodgas@users.noreply.github.com> Date: Mon, 1 Aug 2022 22:46:36 +0200 Subject: [PATCH] Update 5-range-odd.js Hello! In the test case like rangeOdd(15, 14) we will have 0 value of the len identifier. It is better to use (len <= 0) instead of (len < 0 ) in the if statement. It will prevent initiation of new array in 6th string of the code. --- Solutions/5-range-odd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Solutions/5-range-odd.js b/Solutions/5-range-odd.js index 908eedb..b1036c9 100644 --- a/Solutions/5-range-odd.js +++ b/Solutions/5-range-odd.js @@ -2,7 +2,7 @@ const rangeOdd = (begin, end) => { const len = Math.ceil((end - begin) / 2); - if (len < 0) return []; + if (len <= 0) return []; const array = new Array(len); let i = 0; for (let n = begin; n <= end; n++) {