diff --git a/1-exercises/A-undefined/exercise.js b/1-exercises/A-undefined/exercise.js index 0acfc78d..119b7b26 100644 --- a/1-exercises/A-undefined/exercise.js +++ b/1-exercises/A-undefined/exercise.js @@ -12,7 +12,7 @@ // Example 1 let a; console.log(a); - +// a doesnt have a value // Example 2 function sayHello() { @@ -21,7 +21,7 @@ function sayHello() { let hello = sayHello(); console.log(hello); - +// // Example 3 function sayHelloToUser(user) { @@ -29,8 +29,9 @@ function sayHelloToUser(user) { } sayHelloToUser(); - +//the user value is undefined in the string // Example 4 let arr = [1,2,3]; console.log(arr[3]); +// this array doesn't have a fourth value (the first value in the array is designated position 0) \ No newline at end of file diff --git a/1-exercises/B-while-loop/exercise.js b/1-exercises/B-while-loop/exercise.js index b459888f..95ede76b 100644 --- a/1-exercises/B-while-loop/exercise.js +++ b/1-exercises/B-while-loop/exercise.js @@ -6,9 +6,16 @@ */ function evenNumbers(n) { - // TODO + if (!n) return + const evenNums = [] + let counter = 0; + while (evenNums.length < n) { + evenNums.push(counter * 2) + counter++; + } + console.log(evenNums.toString()) } - +evenNumbers(1) evenNumbers(3); // should output 0,2,4 evenNumbers(0); // should output nothing evenNumbers(10); // should output 0,2,4,6,8,10,12,14,16,18 diff --git a/1-exercises/D-do-while/exercise.js b/1-exercises/D-do-while/exercise.js index f10d0764..016324d5 100644 --- a/1-exercises/D-do-while/exercise.js +++ b/1-exercises/D-do-while/exercise.js @@ -7,7 +7,13 @@ */ function evenNumbersSum(n) { - // TODO + let sum = 0 + let i = 0 + do { + sum += (i * 2); + i++; + } while (i < n) + return sum } console.log(evenNumbersSum(3)); // should output 6