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
10 changes: 9 additions & 1 deletion 1-exercises/B-while-loop/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@

function evenNumbers(n) {
// TODO
}
let i = 0;
let even = [];
while (i < 2 * n) {
even.push(i);
i += 2;
}
return even.toString();
}
console.log(evenNumbers());

evenNumbers(3); // should output 0,2,4
evenNumbers(0); // should output nothing
Expand Down
14 changes: 11 additions & 3 deletions 1-exercises/C-while-loop-with-array/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@ const BIRTHDAYS = [
"November 15th"
];


function findFirstJulyBDay(birthdays) {
// TODO
}

console.log(findFirstJulyBDay(BIRTHDAYS)); // should output "July 11th"
let i = 0;
while (i < birthdays.length) {
if (birthdays[i][1] === "u") {
return birthdays[i];
}
i++;
}
}

console.log(findFirstJulyBDay(BIRTHDAYS)); // should output "July 11th"
9 changes: 8 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,14 @@
*/

function evenNumbersSum(n) {
// TODO
let i = 0;
let sum = n * (n - 1);
while (i < 5) {
console.log(i);
i++ ;

}

}

console.log(evenNumbersSum(3)); // should output 6
Expand Down
5 changes: 4 additions & 1 deletion 1-exercises/E-for-loop/exercise1.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ while(i < 26) {
console.log(String.fromCharCode(97 + i));
i++;
}
// The output shouldn't change.

for (let i = 0; i < 26; i++); {
console.log(String.fromCharCode(97 + i));
}
4 changes: 4 additions & 0 deletions 1-exercises/E-for-loop/exercise2.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const AGES = [
];

// TODO - Write for loop code here
for(let i = 0; i < WRITERS.length; i++) {
let text = WRITERS[i] + "is" + AGES[i] +"years old";
console.log (text);
}

/*
The output should look something like this:
Expand Down
7 changes: 6 additions & 1 deletion 1-exercises/F-for-of-loop/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ let tubeStations = [
"Oxford Street",
"Tottenham Court Road"
];

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

// TODO Use a for-of loop to capitalise and output each letter in the string seperately.
let str = "codeyourfuture";
for (let H of str){
console.log(H.toUpperCase());
}