diff --git a/1-exercises/A-undefined/exercise.js b/1-exercises/A-undefined/exercise.js index 0acfc78d..7630f112 100644 --- a/1-exercises/A-undefined/exercise.js +++ b/1-exercises/A-undefined/exercise.js @@ -13,15 +13,20 @@ let a; console.log(a); +//a is not defined + // Example 2 function sayHello() { let message = "Hello"; } +// the message is not defined let hello = sayHello(); console.log(hello); +// hello is not defined + // Example 3 function sayHelloToUser(user) { @@ -30,7 +35,11 @@ function sayHelloToUser(user) { sayHelloToUser(); +//user is not defined + // Example 4 let arr = [1,2,3]; console.log(arr[3]); + +// array no 3 does not exist diff --git a/1-exercises/B-while-loop/exercise.js b/1-exercises/B-while-loop/exercise.js index b459888f..9af69c91 100644 --- a/1-exercises/B-while-loop/exercise.js +++ b/1-exercises/B-while-loop/exercise.js @@ -7,6 +7,16 @@ function evenNumbers(n) { // TODO + let array = []; + let i = 0; + while (n > array.length) { + if (i % 2 === 0) { + array.push(i); + } + i++; + } + + console.log(array); } evenNumbers(3); // should output 0,2,4 diff --git a/1-exercises/C-while-loop-with-array/exercise.js b/1-exercises/C-while-loop-with-array/exercise.js index d584cd75..9eebc1de 100644 --- a/1-exercises/C-while-loop-with-array/exercise.js +++ b/1-exercises/C-while-loop-with-array/exercise.js @@ -18,6 +18,11 @@ const BIRTHDAYS = [ function findFirstJulyBDay(birthdays) { // TODO + let i = 0; + while (i < birthdays.length) { + if (birthdays[i].includes("July")) return birthdays[i]; + i++; + } } console.log(findFirstJulyBDay(BIRTHDAYS)); // should output "July 11th" diff --git a/1-exercises/D-do-while/exercise.js b/1-exercises/D-do-while/exercise.js index f10d0764..ae24fd3c 100644 --- a/1-exercises/D-do-while/exercise.js +++ b/1-exercises/D-do-while/exercise.js @@ -8,8 +8,6 @@ function evenNumbersSum(n) { // TODO -} - console.log(evenNumbersSum(3)); // should output 6 console.log(evenNumbersSum(0)); // should output 0 console.log(evenNumbersSum(10)); // should output 90 \ No newline at end of file