We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 191a43a + f5f6efa commit cdba6daCopy full SHA for cdba6da
05_sumAll/solution/sumAll-solution.js
@@ -6,8 +6,13 @@ const sumAll = function (min, max) {
6
min = max;
7
max = temp;
8
}
9
+
10
+ // An alternative way to swap the values of min and max like above is to use the array destructuring syntax.
11
+ // Here's an optional article on it: https://www.freecodecamp.org/news/array-destructuring-in-es6-30e398f21d10/
12
+ // if (min > max) [min, max] = [max, min];
13
14
let sum = 0;
- for (let i = min; i < max + 1; i++) {
15
+ for (let i = min; i <= max; i++) {
16
sum += i;
17
18
return sum;
0 commit comments