Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.
Closed
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
5 changes: 5 additions & 0 deletions 1-exercises/A-undefined/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// Example 1
let a;
console.log(a);
No value is assigned to the variable


// Example 2
Expand All @@ -22,15 +23,19 @@ function sayHello() {
let hello = sayHello();
console.log(hello);

The function does not contain any parameters


// Example 3
function sayHelloToUser(user) {
console.log(`Hello ${user}`);
}

sayHelloToUser();
There is no variable


// Example 4
let arr = [1,2,3];
console.log(arr[3]);
There is no value for index 3
10 changes: 10 additions & 0 deletions 1-exercises/B-while-loop/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@

function evenNumbers(n) {
// TODO
let i = 0;
let text = '';
while (i < n) {
let sum;
sum = i * 2;
text += sum + ',';
i++;
}
console.log(text);

}

evenNumbers(3); // should output 0,2,4
Expand Down
16 changes: 15 additions & 1 deletion 1-exercises/C-while-loop-with-array/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,21 @@ const BIRTHDAYS = [
];

function findFirstJulyBDay(birthdays) {
// console.log(BIRTHDAYS.length);
// TODO
let i = 0;
while (i < BIRTHDAYS.length){
// console.log('line 24;',BIRTHDAYS[i])

// console.log('line 26;',BIRTHDAYS[i].includes('July'))

if (BIRTHDAYS[i].includes('July') ) {
return BIRTHDAYS[i]

}
i++;

}
}

console.log(findFirstJulyBDay(BIRTHDAYS)); // should output "July 11th"
console.log('this is the last line;',findFirstJulyBDay(BIRTHDAYS)); // should output "July 11th"
5 changes: 5 additions & 0 deletions 1-exercises/D-do-while/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

function evenNumbersSum(n) {
// TODO
let i = 0;
do {
i++;
} while (evenNumbersSum);
console.log(evenNumbersSum);
}

console.log(evenNumbersSum(3)); // should output 6
Expand Down
5 changes: 3 additions & 2 deletions 1-exercises/E-for-loop/exercise1.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@


// Change the below code to use a for loop instead of a while loop.
let i = 0;
while(i < 26) {

for( let i = 0; i < 26; i++ ) {
console.log(String.fromCharCode(97 + i));
i++;
}

// The output shouldn't change.
6 changes: 6 additions & 0 deletions 1-exercises/E-for-loop/exercise2.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ const AGES = [
];

// TODO - Write for loop code here
for (let i = 0; i < WRITERS.length; i++) {
let writersName = WRITERS[i];
let ageNumber = AGES[i];

console.log(writersName,ageNumber);

}
/*
The output should look something like this:

Expand Down
8 changes: 8 additions & 0 deletions 1-exercises/F-for-of-loop/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ let tubeStations = [
"Tottenham Court Road"
];

for (let streetName of tubeStations) {
console.log(streetName);
}


// TODO Use a for-of loop to capitalise and output each letter in the string seperately.
let str = "codeyourfuture";

for (let street of str){
console.log(street)
}
10 changes: 10 additions & 0 deletions 2-mandatory/1-weather-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,18 @@
- Hint: you can call the temperatureService function from your function
*/

let temperature = [London, Paris, Barcelona, Dubai, Mumbai, Sao Paulo, Lagos];
let degree = [10, 12, 17, 27, 29, 23, 33];

function getTemperatureReport(cities) {
// TODO
for (let i = 0; i < temperature.length; i++) {
let temp = temperature[i];
let deg = degree[i];

console.log(temp, deg);

}
}


Expand Down