diff --git a/05_sumAll/solution/sumAll-solution.js b/05_sumAll/solution/sumAll-solution.js index 50c78fe..c4b38e3 100644 --- a/05_sumAll/solution/sumAll-solution.js +++ b/05_sumAll/solution/sumAll-solution.js @@ -1,11 +1,8 @@ const sumAll = function (min, max) { if (!Number.isInteger(min) || !Number.isInteger(max)) return "ERROR"; if (min < 0 || max < 0) return "ERROR"; - if (min > max) { - const temp = min; - min = max; - max = temp; - } + if (min > max) [min, max] = [max, min]; + let sum = 0; for (let i = min; i < max + 1; i++) { sum += i;