From f484962e264540d1677a044a5d70c69ff477f821 Mon Sep 17 00:00:00 2001 From: username Date: Sun, 27 Oct 2024 13:51:01 +0600 Subject: [PATCH 1/6] day9/task1-easy --- .../09_day_starter/index.html | 27 ++-- .../09_day_starter/scripts/main.js | 124 +++++++++++++++++- 2 files changed, 134 insertions(+), 17 deletions(-) diff --git a/09_Day_Higher_order_functions/09_day_starter/index.html b/09_Day_Higher_order_functions/09_day_starter/index.html index cbf51280e..aef0a372f 100644 --- a/09_Day_Higher_order_functions/09_day_starter/index.html +++ b/09_Day_Higher_order_functions/09_day_starter/index.html @@ -1,17 +1,14 @@ - - - 30DaysOfJavaScript:09 Day - - - -

30DaysOfJavaScript:09 Day

-

Functional Programming

- - - - - - - \ No newline at end of file + + 30DaysOfJavaScript:09 Day + + + +

30DaysOfJavaScript:09 Day

+

Functional Programming

+ + + + + diff --git a/09_Day_Higher_order_functions/09_day_starter/scripts/main.js b/09_Day_Higher_order_functions/09_day_starter/scripts/main.js index c6045c836..a8c396797 100644 --- a/09_Day_Higher_order_functions/09_day_starter/scripts/main.js +++ b/09_Day_Higher_order_functions/09_day_starter/scripts/main.js @@ -1,2 +1,122 @@ -console.log(countries) -alert('Open the console and check if the countries has been loaded') \ No newline at end of file +const countries2 = ['Finland', 'Sweden', 'Denmark', 'Norway', 'Iceland'] +const names = ['Asabeneh', 'Mathias', 'Elias', 'Brook'] +const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] +const products = [ + { product: 'banana', price: 3 }, + { product: 'mango', price: 6 }, + { product: 'potato', price: ' ' }, + { product: 'avocado', price: 8 }, + { product: 'coffee', price: 10 }, + { product: 'tea', price: '' }, +] + +//Task1-easy +//Task2-easy +//Task3-easy +function callbackCountries(element) { + console.log(element) +} + +countries2.forEach(callbackCountries) + +//Task4-easy +names.forEach(elem => { + console.log(elem) +}) + +//Task5-easy +numbers.forEach(elem => { + console.log(elem) +}) + +//Task6-easy +const newCountries2 = countries2.map(country => country.toLocaleUpperCase()) +console.log(newCountries2) + +//Task7-easy +const lengthCountries2 = countries2.map(elem => elem.length) +console.log(lengthCountries2) + +//Task8-easy +const numbersSqr = numbers.map(num => num * num) +console.log(numbersSqr) + +//Task9easy +const namesUpperCase = names.map(name => name.toUpperCase) +console.log(namesUpperCase) + +//Task10-easy +const price = products.map( + product => `Price of ${product.product} = ${product.price}` +) +console.log(price) + +//Task11-easy +const countriesWithLand = countries2.filter(country => country.includes('land')) +console.log(countriesWithLand) + +//Task12-easy +const countriesSix = countries2.filter(country => country.length == 6) +console.log(countriesSix) + +//Task13-easy +const countriesSixAndMore = countries2.filter(country => country.length >= 6) +console.log(countriesSixAndMore) + +//Task14-easy +const countriesStartsWithE = countries2.filter(country => country[0] == 'E') +console.log(countriesStartsWithE) + +//Task15-easy +const priceWithValue = products.filter( + product => typeof product.price == 'number' +) +console.log(priceWithValue) + +//Task16-easy +const arr = [1, 'string', 'lntlns', 'lekj', 590] + +function getStringLists(array) { + const newArray = array.filter(elem => typeof elem == 'string') + + return newArray +} +console.log(getStringLists(arr)) + +//Task17-easy +const sum = numbers.reduce((acc, cur) => acc + cur) +console.log(sum) + +//Task18-easy +const countriesToString = countries2.reduce((acc, cur, index) => index != countries2.length - 1 ? acc.concat(`, ${cur}`) : acc.concat(`, and ${cur} are north European countries`)) +console.log(countriesToString) + +//Task19-easy +//Task20-easy +const namesLength = names.some(name => name.length > 7) +console.log(namesLength) + +//Task21-easy +const countriesContainsLand = countries2.every(country => + country.includes('land') +) +console.log(countriesContainsLand) + +//Task22-easy +//Task23-easy +const countryWithSixLetters = countries2.find(country => country.length == 6) +console.log(countryWithSixLetters) + +//Task24-easy +const countryWithSixLetters2 = countries2.findIndex( + country => country.length == 6 +) +console.log(countryWithSixLetters2) + +//Task25-easy +const norwayPosition = countries2.findIndex(country => country == 'Norway') +console.log(norwayPosition) + +//Task26-easy +const russiaPosition = countries2.findIndex(country => country == 'Russia') +console.log(russiaPosition) From bc4f82226f20ca52406372ad66c00b3e45e56526 Mon Sep 17 00:00:00 2001 From: username Date: Sun, 27 Oct 2024 13:55:45 +0600 Subject: [PATCH 2/6] day10/task1-easy --- .../10_day_starter/data/countries_data.js | 2 +- .../10_day_starter/scripts/main.js | 38 ++++++++++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/10_Day_Sets_and_Maps/10_day_starter/data/countries_data.js b/10_Day_Sets_and_Maps/10_day_starter/data/countries_data.js index 92acddd21..848f14bca 100644 --- a/10_Day_Sets_and_Maps/10_day_starter/data/countries_data.js +++ b/10_Day_Sets_and_Maps/10_day_starter/data/countries_data.js @@ -265,7 +265,7 @@ const countries = [ }, { name: 'United States Minor Outlying Islands', - capital: '', + capital: '',f languages: ['English'], population: 300, flag: 'https://restcountries.eu/data/umi.svg', diff --git a/10_Day_Sets_and_Maps/10_day_starter/scripts/main.js b/10_Day_Sets_and_Maps/10_day_starter/scripts/main.js index c6045c836..60811ba1e 100644 --- a/10_Day_Sets_and_Maps/10_day_starter/scripts/main.js +++ b/10_Day_Sets_and_Maps/10_day_starter/scripts/main.js @@ -1,2 +1,36 @@ -console.log(countries) -alert('Open the console and check if the countries has been loaded') \ No newline at end of file +//Task1-easy +const empty = new Set() +console.log(empty) + +//Task2-easy +const numbers = new Set() + +for (let i = 0; i <= 10; i++) { + numbers.add(i) +} + +console.log(numbers) + +//Task3-easy +numbers.delete(1) +console.log(numbers) + +//Task4-easy +numbers.clear() +console.log(numbers) + +//Task5-easy +const words = ['hello', 'text', 'hello', 'plant', 'tree'] + +const wordsSet = new Set(words) + +console.log(wordsSet) + +//Task6-easy +const countries3 = ['Finland', 'Sweden', 'Norway'] + +const countriesMap = new Map() + +for (let i = 0; i <= countries3.length - 1; i++) { + countriesMap.set(countries3[i], countries3[i].length) +} From fc4a577771835bbc6a84e2b5cd11510125f947a3 Mon Sep 17 00:00:00 2001 From: username Date: Sun, 27 Oct 2024 13:58:32 +0600 Subject: [PATCH 3/6] day10/task2-medium --- .../10_day_starter/scripts/main.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/10_Day_Sets_and_Maps/10_day_starter/scripts/main.js b/10_Day_Sets_and_Maps/10_day_starter/scripts/main.js index 60811ba1e..b3fdc4b9e 100644 --- a/10_Day_Sets_and_Maps/10_day_starter/scripts/main.js +++ b/10_Day_Sets_and_Maps/10_day_starter/scripts/main.js @@ -34,3 +34,22 @@ const countriesMap = new Map() for (let i = 0; i <= countries3.length - 1; i++) { countriesMap.set(countries3[i], countries3[i].length) } + +//Task1-medium +const a = [4, 5, 8, 9] +const b = [3, 4, 5, 7] + +const A = new Set(a) +const B = new Set(b) + +let c = new Set([...a, ...b]) + +console.log(c) + +//Task2-medium +c = new Set(a.filter(num => B.has(num))) +console.log(c) + +//Task3-medium +c = new Set(a.filter(num => !B.has(num))) +console.log(c) From 0b0bf1367bf569156f92df745b3efd9271c50ab8 Mon Sep 17 00:00:00 2001 From: username Date: Sun, 27 Oct 2024 14:01:21 +0600 Subject: [PATCH 4/6] day10/task3-hard --- 10_Day_Sets_and_Maps/10_day_starter/scripts/main.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/10_Day_Sets_and_Maps/10_day_starter/scripts/main.js b/10_Day_Sets_and_Maps/10_day_starter/scripts/main.js index b3fdc4b9e..125dce06d 100644 --- a/10_Day_Sets_and_Maps/10_day_starter/scripts/main.js +++ b/10_Day_Sets_and_Maps/10_day_starter/scripts/main.js @@ -53,3 +53,11 @@ console.log(c) //Task3-medium c = new Set(a.filter(num => !B.has(num))) console.log(c) + +console.log(countriesMap) + +//Task1-hard +console.log(countries.length) + +//Task2-hard +function mostSpokenLanguages(countries, n) {} From cb26876ad97a1cb1e4c142f7aa1fd2a09a23bfcc Mon Sep 17 00:00:00 2001 From: username Date: Sun, 27 Oct 2024 14:03:37 +0600 Subject: [PATCH 5/6] day11/task1-easy --- .../11_day_starter/index.html | 27 +++++++++---------- .../11_day_starter/scripts/main.js | 24 +++++++++++++++-- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/11_Day_Destructuring_and_spreading/11_day_starter/index.html b/11_Day_Destructuring_and_spreading/11_day_starter/index.html index 1c2ed8db9..a0747d3a1 100644 --- a/11_Day_Destructuring_and_spreading/11_day_starter/index.html +++ b/11_Day_Destructuring_and_spreading/11_day_starter/index.html @@ -1,17 +1,14 @@ - - - 30DaysOfJavaScript:11 Day - - - -

30DaysOfJavaScript:11 Day

-

Destructuring and Spread

- - - - - - - \ No newline at end of file + + 30DaysOfJavaScript:11 Day + + + +

30DaysOfJavaScript:11 Day

+

Destructuring and Spread

+ + + + + diff --git a/11_Day_Destructuring_and_spreading/11_day_starter/scripts/main.js b/11_Day_Destructuring_and_spreading/11_day_starter/scripts/main.js index c6045c836..c949e7729 100644 --- a/11_Day_Destructuring_and_spreading/11_day_starter/scripts/main.js +++ b/11_Day_Destructuring_and_spreading/11_day_starter/scripts/main.js @@ -1,2 +1,22 @@ -console.log(countries) -alert('Open the console and check if the countries has been loaded') \ No newline at end of file +//Task1-easy +const constants = [2.72, 3.14, 9.81, 37, 100] +let [e, pi, gravity, humanBodyTemp, waterBoilingTemp] = constants + +console.log(e, pi, gravity, humanBodyTemp, waterBoilingTemp) + +//Task2-easy +const countries2 = ['Finland', 'Estonia', 'Sweden', 'Denmark', 'Norway'] +let [fin, est, sw, den, nor] = countries2 + +console.log(fin, est, sw, den, nor) + +//Task3-easy +const rectangle = { + width: 20, + height: 10, + area: 200, + perimeter: 60, +} + +let { width, height, area, perimeter } = rectangle +console.log(width, height, area, perimeter) From 0cf1a0f491d0806dd1afa654121ca3bed48aa6e9 Mon Sep 17 00:00:00 2001 From: username Date: Sun, 27 Oct 2024 14:06:13 +0600 Subject: [PATCH 6/6] day11/task2-medium --- .../11_day_starter/scripts/main.js | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/11_Day_Destructuring_and_spreading/11_day_starter/scripts/main.js b/11_Day_Destructuring_and_spreading/11_day_starter/scripts/main.js index c949e7729..7872aaacf 100644 --- a/11_Day_Destructuring_and_spreading/11_day_starter/scripts/main.js +++ b/11_Day_Destructuring_and_spreading/11_day_starter/scripts/main.js @@ -20,3 +20,60 @@ const rectangle = { let { width, height, area, perimeter } = rectangle console.log(width, height, area, perimeter) + +//Task1-medium +const users = [ + { + name: 'Brook', + scores: 75, + skills: ['HTM', 'CSS', 'JS'], + age: 16, + }, + { + name: 'Alex', + scores: 80, + skills: ['HTM', 'CSS', 'JS'], + age: 18, + }, + { + name: 'David', + scores: 75, + skills: ['HTM', 'CSS'], + age: 22, + }, + { + name: 'John', + scores: 85, + skills: ['HTML'], + age: 25, + }, + { + name: 'Sara', + scores: 95, + skills: ['HTM', 'CSS', 'JS'], + age: 26, + }, + { + name: 'Martha', + scores: 80, + skills: ['HTM', 'CSS', 'JS'], + age: 18, + }, + { + name: 'Thomas', + scores: 90, + skills: ['HTM', 'CSS', 'JS'], + age: 20, + }, +] + +for (let { name, scores, skills, age } of users) { + console.log(name, scores, skills, age) +} + +//Task2-medium +for (let { name, skills } of users) { + if (skills.length < 2) { + console.log(name, skills) + } +}