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
6 changes: 4 additions & 2 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);

//beacuse variable don't have value

// Example 2
function sayHello() {
Expand All @@ -21,6 +21,7 @@ function sayHello() {

let hello = sayHello();
console.log(hello);
//beacuse doesn't have return value


// Example 3
Expand All @@ -29,8 +30,9 @@ function sayHelloToUser(user) {
}

sayHelloToUser();

//don't have value

// Example 4
let arr = [1,2,3];
console.log(arr[3]);
//doesn't have i=3 beacuse first start with 0, 1 , 2
11 changes: 10 additions & 1 deletion 1-exercises/B-while-loop/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@
*/

function evenNumbers(n) {
// TODO
let even = 0;
let arr = []
let i = 0;
while(i < n ){
arr.push(even)
even=even+2
i++
}
return arr.join(",")
}
console.log(evenNumbers(10))

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

function findFirstJulyBDay(birthdays) {
// TODO
let i = 5;
while (i < birthdays.length){
return birthdays[i];
}
i++;
}

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

function evenNumbersSum(n) {
// TODO
let sum=0;
let i = 0;
let even = 0;
do{
sum = sum + even
even= even +2;
i++
}while(i< n)
return sum

}

console.log(evenNumbersSum(3)); // should output 6
Expand Down
3 changes: 3 additions & 0 deletions 1-exercises/E-for-loop/exercise1.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ let i = 0;
while(i < 26) {
console.log(String.fromCharCode(97 + i));
i++;
for (let i = 0; i < 26; i++){
console.log(String.fromCharCode(97 + i));
}
}
// The output shouldn't change.
3 changes: 3 additions & 0 deletions 1-exercises/E-for-loop/exercise2.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const AGES = [
63,
49
];
for (let i = 0; i < AGES.length; i++){
console.log(`${WRITERS[i]} is ${AGES[i]} years old`);
}

// TODO - Write for loop code here

Expand Down
4 changes: 3 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,9 @@ let tubeStations = [
"Oxford Street",
"Tottenham Court Road"
];

for(let item of tubeStations){
console.log(item)
}

// TODO Use a for-of loop to capitalise and output each letter in the string seperately.
let str = "codeyourfuture";
8 changes: 7 additions & 1 deletion 2-mandatory/1-weather-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
*/

function getTemperatureReport(cities) {
// TODO
let citysList=[];
for (let city of cities) {
let cityTemp = temperatureService(city);
citysList.push(`The temperature in ${city} is ${cityTemp} degrees`);
}
return citysList;
}


Expand All @@ -21,6 +26,7 @@ function getTemperatureReport(cities) {
function temperatureService(city) {
let temparatureMap = new Map();


temparatureMap.set('London', 10);
temparatureMap.set('Paris', 12);
temparatureMap.set('Barcelona', 17);
Expand Down
5 changes: 5 additions & 0 deletions 2-mandatory/2-retrying-random-numbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ function generateRandomNumber() {

function getRandomNumberGreaterThan50() {
// TODO - implement using a do-while loop
let number = 0;
do{
number = generateRandomNumber();
}while(number <= 50);
return number;
}

/* ======= TESTS - DO NOT MODIFY ===== */
Expand Down
1 change: 1 addition & 0 deletions 2-mandatory/3-financial-times.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
function potentialHeadlines(allArticleTitles) {
// TODO

}

/*
Expand Down
4 changes: 4 additions & 0 deletions 3-extra/1-factorial.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

function factorial(input) {
// TODO
let result = 1;
for(let i= 1; i<=input; i++){
result* =i;
}
}

/* ======= TESTS - DO NOT MODIFY ===== */
Expand Down