Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions 1-exercises/A-undefined/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// Example 1
let a;
console.log(a);

// a doesnt have a value

// Example 2
function sayHello() {
Expand All @@ -21,16 +21,17 @@ function sayHello() {

let hello = sayHello();
console.log(hello);

//

// Example 3
function sayHelloToUser(user) {
console.log(`Hello ${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)
11 changes: 9 additions & 2 deletions 1-exercises/B-while-loop/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 7 additions & 1 deletion 1-exercises/D-do-while/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down