diff --git a/01_helloWorld/helloWorld.js b/01_helloWorld/helloWorld.js index df27036..4d4888f 100644 --- a/01_helloWorld/helloWorld.js +++ b/01_helloWorld/helloWorld.js @@ -1,5 +1,5 @@ const helloWorld = function() { - return '' + return '' }; module.exports = helloWorld; diff --git a/05_sumAll/solution/sumAll-solution.js b/05_sumAll/solution/sumAll-solution.js index ae01a5b..588d311 100644 --- a/05_sumAll/solution/sumAll-solution.js +++ b/05_sumAll/solution/sumAll-solution.js @@ -1,6 +1,13 @@ const sumAll = function (min, max) { + // The Line of code below returns "ERROR" which is a string if min and max aren't numbers if (!Number.isInteger(min) || !Number.isInteger(max)) return "ERROR"; + // This line of code also returns "ERROR" is min and max are less than 0 if (min < 0 || max < 0) return "ERROR"; + /* + The block of code below checks if min is greater than max + And if that is true, a new variable called 'temp' is created + The value of 'temp' will be equal to min and max will be equal to temp + */ if (min > max) { const temp = min; min = max; @@ -12,6 +19,10 @@ const sumAll = function (min, max) { // if (min > max) [min, max] = [max, min]; let sum = 0; + /* We're running a for loop below which + Initializes the value of i to be that of min and we're checking if i is less than or equal to max + And if those conditions are true, we'll be adding i to value of sum + */ for (let i = min; i <= max; i++) { sum += i; }