├── .gitignore ├── Day01_Introduction ├── comments.js ├── datatypes.js └── variable.js ├── Day02_Data_Types ├── exerciseLevel_1.js ├── exerciseLevel_2.js └── exerciseLevel_3.js ├── Day03_Boolean_Operators_Date ├── exerciseLevel1.js ├── exerciseLevel2.js └── exerciseLevel3.js ├── Day04_Conditionals ├── exerciseLevel1.js ├── exerciseLevel2.js └── exerciseLevel3.js ├── Day05_Arrays ├── level1.js ├── level2 │ ├── countries.js │ ├── main.js │ └── web_techs.js └── level3.js ├── Day06_Loops ├── exerciseLevel1.js ├── exerciseLevel2 │ ├── countries.js │ ├── master.js │ └── web_techs.js └── exerciseLevel3.js ├── Day07_Functions ├── level1.js ├── level2.js └── level3.js ├── Day08_Objects ├── countries.js ├── level1.js ├── level2.js └── level3.js ├── Day09_High_Order_Functions ├── level1.js ├── level2.js └── level3.js ├── Day10_Maps_Sets ├── countries.js ├── level1.js ├── level2.js └── level3.js ├── Day11_Destructuring_Spreading ├── countries.js ├── level1.js ├── level2.js └── level3.js ├── Day12_RegularExpressions ├── level1.js ├── level2.js └── level3.js ├── Day13_Console_Object ├── level1.js ├── level2.js └── level3.js ├── Day14_Error_Handling ├── level1.js ├── level2.js └── level3.js ├── Day15_Classes ├── level3.js └── level_1_and_2.js ├── Day16_JSON ├── level1.js └── level_2_and_3.js ├── Day17_Web_Storages └── level_1_2_3.js ├── Day19_Closures └── level_1_2_3.js ├── Day20_Writing_Clean_Code └── README20.md ├── Day21_DOM ├── indexDOM.html ├── level1.js ├── level2.js ├── level3_DOM.js └── level_1_2_index.html ├── Day22_Manipulating_DOM ├── Project_1 │ ├── index.html │ └── main.js ├── Project_2 │ ├── countries.js │ ├── index.html │ └── script.js └── Project_3 │ ├── index.html │ ├── main.js │ └── projectInfo.js ├── Day22_Manipulating_DOM_level1_solution ├── numberDisplay.css ├── numberDisplay.html ├── numberDisplay.js └── readme.txt ├── Day23_EventListeners ├── project1_NumbersGenerator │ ├── index.html │ ├── main.js │ └── style.css └── project2_ASCII_CodeVisualiser │ └── index.html ├── Day25 Mini_Project: Solution_to_World_Countries_Data_Visualization_1 ├── readme.txt ├── visualizingData.css ├── visualizingData.html └── visualizingData.js ├── Day26_Mini_Project_solution: World_Countries_Data_Visualization_2 ├── Readme ├── globe-2.jpg ├── map_image.jpg ├── searchingData.css ├── searchingData.js └── serachingData.html ├── Day_27_Mini_Project_Solution: Portfolio ├── Readme ├── miniPortfolio.css ├── miniPortfolio.html └── miniPortfolio.js └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # ignore everything in the root except the "wp-content" directory. 2 | !wp-content/ 3 | 4 | # ignore everything in the "wp-content" directory, except: 5 | # "mu-plugins", "plugins", "themes" directory 6 | wp-content/* 7 | !wp-content/mu-plugins/ 8 | !wp-content/plugins/ 9 | !wp-content/themes/ 10 | 11 | # ignore these plugins 12 | wp-content/plugins/hello.php 13 | 14 | # ignore specific themes 15 | wp-content/themes/twenty*/ 16 | 17 | # ignore node dependency directories 18 | node_modules/ 19 | 20 | # ignore log files and databases 21 | *.log 22 | *.sql 23 | *.sqlite 24 | -------------------------------------------------------------------------------- /Day01_Introduction/comments.js: -------------------------------------------------------------------------------- 1 | // Comments can make code readable 2 | // Welcome to 30DaysOfJavaScript 3 | 4 | /** 5 | comments can make readable, easy 6 | to reuse and informative 7 | **/ 8 | 9 | 10 | -------------------------------------------------------------------------------- /Day01_Introduction/datatypes.js: -------------------------------------------------------------------------------- 1 | // use *typeof* operator to check the datatypes of variables 2 | // I import the all variable from *variable.js* file 3 | 4 | // create variables and assign values 5 | var name = "John"; 6 | var condition = true; 7 | var unknown = undefined; 8 | var empty = null; 9 | 10 | // checking the datatypes 11 | console.log("Name's datatype: ", typeof name); 12 | console.log("condition's datatype: ", typeof condition); 13 | console.log("unknown's datatype: ", typeof unknown); 14 | console.log("empty's datatype: ", typeof empty); 15 | 16 | // 10. declare two vars myAge and yourAge assign them values; 17 | let myAge = 17; 18 | let yourAge = 23; 19 | 20 | console.log("I am ", myAge, " years old"); 21 | console.log("You are ", yourAge, "years old"); 22 | 23 | 24 | -------------------------------------------------------------------------------- /Day01_Introduction/variable.js: -------------------------------------------------------------------------------- 1 | // created variables file 2 | // declare 4 variables without assigning values 3 | let var1, var2, var3, var4; 4 | 5 | // declare 4 variable assigning values to them 6 | let one = 1; 7 | let name = "John"; 8 | let status = undefined; 9 | let money = null; // ;) 10 | 11 | // declare variable to store firstname, lastname, marital status, country and age in multiple lines; 12 | let firstName = "Hamza"; 13 | let lastName = "Mateen"; 14 | let isMarried = false; 15 | let country = "Pakistan"; 16 | let age = 17; 17 | 18 | // now storing using one line 19 | let firstName, lastName, isMarried, country, age = "Hamza", "Mateen", false, "Pakistan", 17; 20 | 21 | 22 | -------------------------------------------------------------------------------- /Day02_Data_Types/exerciseLevel_1.js: -------------------------------------------------------------------------------- 1 | /** LEVEL 1 Challenges **/ 2 | // 1. 3 | let challenge = '30 Days Of JavaScript'; 4 | // 2. 5 | console.log(challenge); 6 | // 3. 7 | console.log(challenge.length); 8 | // 4. 9 | challenge.toUpperCase(); 10 | console.log(challenge) 11 | // 5. 12 | challenge.toLowerCase(); 13 | console.log(challenge) 14 | // 6. 15 | let firstWord = challenge.substr(0, 2); 16 | // 7. slice out 'Days Of JavaScript' 17 | let lastWords = challenge.substring(3, challenge.length); 18 | console.log(firstWord, lastWords); 19 | // 8. 20 | console.log(challenge.includes("Script")); 21 | // 9. Split string into array 22 | let arr = challenge.split(" ") // split by spaces 23 | // 10. 24 | let arr_2 = 'Facebook, Google, Microsoft, Apple, IBM, Oracle, Amazon'.split(", "); 25 | // 12 26 | const changed = challenge.replace("JavaScript", "Python"); 27 | console.log(changed); 28 | // 13 29 | let charAt15 = challenge.charAt(15); 30 | // 14 31 | let charCodeOf_J = challenge.charCodeAt(11) // J is at 11th index 32 | // 15 33 | let firstOccurranceOf_a = challenge.indexOf("a", 1); 34 | // 16 35 | let lastIndexOf_a = challenge.lastIndexOf("a"); 36 | // 17 37 | const sentence = "You cannot end a sentence with because because because is a conjunction"; 38 | let firstOccurBecause = sentence.indexOf("because", 1); 39 | // 18 40 | let lastOccurBecause = sentence.lastIndexOf("because"); 41 | // 19 42 | firstOccurBecause = sentence.search("because", 1); 43 | console.log(firstOccurBecause); 44 | // 20 45 | let trimmed = ' 30 Days Of JavaScript '.trim(); 46 | // 21 47 | let startsWith30 = challenge.startsWith("30"); 48 | // 22 49 | let endsWith_t = challenge.endsWith("t"); 50 | // 23 51 | let pattern = /a/gi; 52 | let listOfAll_a = challenge.match(pattern); 53 | console.log(listOfAll_a); 54 | // 24 55 | let merged = "30 Days Of ".concat("JavaScript"); 56 | // 25 57 | console.log("30 Days Of JavaScript".repeat(2)); 58 | 59 | /** This is so much fun! :) 60 | -------------------------------------------------------------------------------- /Day02_Data_Types/exerciseLevel_2.js: -------------------------------------------------------------------------------- 1 | /** LEVEL 2 Challenges **/ 2 | // 1 3 | console.log("There is no exercise better for\ heart than reaching down and lifting\ people up.") 4 | // 2 ... screen size was small so ;) 5 | console.log(`​Love is not patronizing and charity\ isn't about pity, it is about love\. Charity and love are the same\ -- with charity you give love\, so don't just give money but reach out y\ our hand instead.​`) 6 | // 3 7 | let typeOf10 = typeof '10'; // it's string 8 | typeOf10 = typeof parseInt('10') 9 | console.log(typeOf10); 10 | // 4 11 | let valueOf9_8 = parseFloat('9.8') // value is 9.8 exactly so we will change it to 10 12 | valueOf9_8 = Math.ceil(valueOf9_8); 13 | console.log(valueOf9_8); 14 | // 5 15 | let onInPython = "Python".includes("on"); 16 | let onInJargon = "jargon".includes("on"); 17 | console.log("\'on\' is present in both Python and Jargon: ", onInPython == onInJargon); 18 | // 6 19 | console.log("I hope this course is not jargon.".includes("jargon")); 20 | // 7 21 | let randomNumber = Math.floor(Math.random() * 100); 22 | console.log(randomNumber); 23 | // 8 24 | let randIn50to100 = Math.floor(Math.random()*51) +50; 25 | console.log(randIn50to100); 26 | // 9 27 | let randIn0to255 = Math.floor(Math.random()*255); 28 | console.log(randIn0to255); 29 | // 10. Access the 'JavaScript' chars using random numbers 30 | let js = 'JavaScript'; 31 | let randomIndex = Math.floor(Math.random() * (js.length - 1)); 32 | console.log(js[randomIndex]); 33 | // 11: Print the pattern 34 | console.log("1\t1\t1\t1\t1\n2\t1\t2\t4\t8\n3\t1\t3\t9\t27\n4\t1\t4\t16\t64\n5\t1\t5\t25\t125"); 35 | // 12 36 | let sentence = "You cannot end a sentence with because because because is a conjunction"; 37 | let becauseAll = sentence.substr(sentence.indexOf("because", 1), ("because".length * 3) +2); // add 2 for two spaces 38 | console.log(becauseAll); 39 | 40 | /** Very fun bite-sized challenges! :) **/ 41 | -------------------------------------------------------------------------------- /Day02_Data_Types/exerciseLevel_3.js: -------------------------------------------------------------------------------- 1 | /** LEVEL 3 Challenges **/ 2 | // 1. 3 | let quote = 'Love is the best thing in this world. Some found their love and some are still looking for their love.'; 4 | let pattern = /love/gi 5 | let loveCount = quote.match(pattern).length; 6 | console.log(loveCount); 7 | 8 | // 2 9 | let sentence = "You cannot end a sentence with because because because is a conjunction"; 10 | let pattern2 = /because/gi; 11 | let becauseCount = sentence.match(pattern2).length; 12 | console.log(becauseCount); 13 | // 3: clean the sentence and find the frequent word 14 | const quote2 = "%I $am@% a %tea@cher%, &and& I lo%#ve %te@a@ching%;. The@re $is no@th@ing; &as& mo@re rewarding as educa@ting &and& @emp%o@weri@ng peo@ple. ;I found tea@ching m%o@re interesting tha@n any ot#her %jo@bs. %Do@es thi%s mo@tiv#ate yo@u to be a tea@cher!? %Th#is 30#Days&OfJavaScript &is al@so $the $resu@lt of &love& of tea&ching"; 15 | const Hash = /#/g; 16 | const At = /@/g; 17 | const And = /&/g; 18 | const ExcMark = /!/g; 19 | const QuestMark = /\?/g; 20 | const Dollar = /\$/g; 21 | const Percent = /\%/g; 22 | 23 | const cleanedQuote = quote2.replace(Hash, "").replace(At, "").replace(And, "").replace(QuestMark, "").replace(ExcMark, "").replace(Dollar, "").replace(Percent, ""); 24 | console.log(cleanedQuote); 25 | /** now counting the most frequent word **/ 26 | // 4 27 | const words = 'He earns 5000 euro from salary per month, 10000 euro annual bonus, 15000 euro online courses per month.'; 28 | 29 | const digitPattern = /\d+/g; 30 | let digitWords = words.match(digitPattern); 31 | 32 | let inc1 = parseInt(digitWords[0]); 33 | let inc2 = parseInt(digitWords[1]); 34 | let inc3 = parseInt(digitWords[2]); 35 | 36 | let totalIncome = inc1 + inc2 + inc3; 37 | console.log(`Total Income: ${totalIncome}`); 38 | 39 | /** Day 2 finished **/ 40 | -------------------------------------------------------------------------------- /Day03_Boolean_Operators_Date/exerciseLevel1.js: -------------------------------------------------------------------------------- 1 | /** LEVEL 1 Challenges **/ 2 | // 1 3 | let firstName = "Hamza"; 4 | let lastName = "Mateen"; 5 | let country = "Pakistan"; 6 | let city = "NYC"; 7 | let age = 17; 8 | let isMarried = false; 9 | let year = 2020; 10 | 11 | console.log(typeof firstName, typeof lastName, typeof country, typeof city, typeof age, typeof isMarried, typeof year); 12 | 13 | // 2 14 | console.log(typeof '10' == 10); 15 | // 3 16 | console.log(parseInt('9.8') == 10); 17 | // 4: 18 | // i: three truthy comparisons 19 | console.log(1 < 2); 20 | console.log("a".length > "".length); 21 | console.log(typeof true == typeof false); 22 | // ii: three falsy comparisons 23 | console.log(1 > 2); 24 | console.log("a".length < "".length); 25 | console.log(typeof true != typeof false); 26 | 27 | // 5 28 | console.log(true, true, false, false, true, true, false, false, false, true, false); 29 | // 6 30 | console.log(true, false, true, true, false, true, true, false, true, true, false); 31 | // 7: use the Date object 32 | const date = new Date; 33 | console.log("Year : ", date.getFullYear()); 34 | console.log("Month: ", date.getMonth() +1); 35 | console.log("Date : ", date.getDate()); 36 | console.log("Day : ", date.getDay()); 37 | console.log("Hours: ", date.getHours()); 38 | console.log("Mins : ", date.getMinutes()); 39 | console.log("Secs : ", Date.now()); 40 | 41 | /** level 1 completed **/ 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Day03_Boolean_Operators_Date/exerciseLevel2.js: -------------------------------------------------------------------------------- 1 | /** LEVEL 2 Challenges **/ 2 | // 1 3 | let b = prompt("Enter base: "); 4 | let h = prompt("Enter height: "); 5 | console.log("The area of the triangle is ", 0.5 * parseFloat(b) * parseFloat(h)); 6 | 7 | // 2 8 | let a = prompt("Enter side a: "); 9 | let b_side = prompt("Enter side b: "); 10 | let c = prompt("Enter side c: "); 11 | console.log("Ther perimeter of the triangle is ", parseFloat(a) + parseFloat(b_side) + parseFloat(c)); 12 | // 3 13 | let length = parseFloat(prompt("Length: ")); 14 | let width = parseFloat(prompt("Width: ")); 15 | console.log("Perimeter: ", 2 * (length + width)); 16 | 17 | // 4 18 | console.log("Area of Circle: ", 2 * parseFloat(prompt("Radius: ")) * Math.PI); 19 | // 5: Calculate the slope 20 | let x_intercept = 1; 21 | let y_intercept =-2; 22 | let slope1 = 2; 23 | 24 | // 6: points are (2, 2) and (6, 10) 25 | let slope2 = (10 - 2)/(6-2); 26 | 27 | // 7 28 | slope2 > slope1 ? console.log("Slope2 is bigger"): console.log("slope1 is bigger"); 29 | // 8: brute force the value of 'x' to find value of 'y' 30 | // --> let x = 1 31 | let x = 1; 32 | let y = x**2 + 6*x + 3**2; 33 | if (y == 0) console.log("y = 0 at x = ", x); 34 | 35 | x = -3; 36 | y = x**2 + 6*x + 3**2; 37 | if (y == 0) console.log("y = 0 at x = ", x); 38 | 39 | // 9 40 | let hrs = parseFloat(prompt("Enter hours: ")); 41 | let ratePerHr = parseFloat(prompt("Enter rate per hours: ")); 42 | console.log("your weekly earning is : ", hrs * ratePerHr); 43 | // 10 44 | console.log("My name is shorter than seven digits: ", "Hamza Mateen".length < 7); 45 | // 11 46 | let firstName = "Hamza"; 47 | let lastName = "Mateen"; 48 | 49 | // 12 50 | let myAge = 234; 51 | let yourAge = 223; 52 | console.log(`I am ${myAge - yourAge} years older than you!`); 53 | 54 | // 13 55 | let birthYear = parseInt(prompt("Enter birth year: ")); 56 | 2020 - birthYear >= 18 ? console.log(`You are ${2020 - birthYear}. You are old enough to drive!`) : console.log(`You are ${2020 - birthYear}. You will be allowed to drive after ${18 - birthYear} years.`); 57 | 58 | // 14 59 | let yrsLived = parseInt(prompt("Enter number of years you live: ")); 60 | console.log(`You lived ${yrsLived * 31536000} seconds!`); 61 | // 15 62 | const d = new Date(); 63 | 64 | let mins = d.getMinutes(); 65 | let hrs = d.getHours(); 66 | 67 | let year = d.getFullYear(); 68 | let month = d.getMonth(); 69 | let date = d.getDate(); 70 | 71 | // Format 1 72 | console.log(`${year}-${month + 1}-${date} ${hrs}:${mins}`); 73 | // Format 2 74 | console.log(`${date}-${month+1}-${year} ${hrs}:${mins}`); 75 | // Format 3 76 | console.log(`${date}/${month+1}/${year} ${hrs}:${mins}`); 77 | /** LEVE 2 Completed **/ 78 | -------------------------------------------------------------------------------- /Day03_Boolean_Operators_Date/exerciseLevel3.js: -------------------------------------------------------------------------------- 1 | /** LEVEL 3 Challenges **/ 2 | // 1: create a human readable format for date 3 | const d = new Date(); 4 | 5 | let mins = d.getMinutes(); 6 | mins < 10 ? '0' + mins.toString(): mins; 7 | let hrs = d.getHours(); 8 | hrs < 10 ? '0' + hrs.toString(): hrs; 9 | 10 | let year = d.getFullYear(); 11 | let month = d.getMonth(); 12 | let date = d.getDate(); 13 | 14 | console.log(`${year}-${month+1}-${date} ${hrs}:${mins}`); 15 | 16 | /** LEVEL 3 completed **/ 17 | -------------------------------------------------------------------------------- /Day04_Conditionals/exerciseLevel1.js: -------------------------------------------------------------------------------- 1 | /** LEVEL 1 Challenges **/ 2 | // 1 3 | let age = parseInt(prompt("Enter your age: ")); 4 | if(age > 17) 5 | console.log("You are old enough to drive."); 6 | else console.log(`you are left with ${18-age} years to drive.`) 7 | 8 | // 2 9 | let myAge = 17; 10 | let yourAge = parseInt(prompt("Enter your age: ")); 11 | 12 | if(myAge < yourAge){ 13 | console.log(`You are ${yourAge - myAge} years older than me.`); 14 | } else console.log(`I am ${myAge - yourAge} years older than you.`); 15 | 16 | // 3 17 | let a = 4; let b = 3; 18 | // way 1 19 | a > b ? console.log(a, " is greater than ", b): console.log(a, " is lesser than ", b); 20 | // way 2 21 | if (a > b) console.log(a, " is greater than ", b); 22 | else console.log(a, " is lesser than ", b); 23 | 24 | // 4 25 | let number = parseInt(prompt("Enter a number: ")); 26 | number % 2 == 0 ? console.log(`${number} is an even number`): console.log(`${number} is an odd number`); 27 | // Level 1 complete 28 | -------------------------------------------------------------------------------- /Day04_Conditionals/exerciseLevel2.js: -------------------------------------------------------------------------------- 1 | /** LEVEL 2 Challenges **/ 2 | // 1 3 | let score = parseInt(prompt("Enter the score ")); 4 | 5 | if (score > 79 && score < 101) 6 | console.log("A"); 7 | else if (score > 69 && score < 80) 8 | console.log("B"); 9 | else if (score > 59 && score < 70) 10 | console.log("C"); 11 | else if (score > 49 && score < 60) 12 | console.log("D"); 13 | else console.log("F"); 14 | 15 | // 2 16 | let month = prompt("Enter the month: "); 17 | let season; 18 | 19 | switch(month) { 20 | case "September": 21 | case "October": 22 | case "November": 23 | season = "Autumn"; 24 | break; 25 | 26 | case "December": 27 | case "January": 28 | case "February": 29 | season = "Winter"; 30 | break; 31 | 32 | case "March": 33 | case "April": 34 | case "May": 35 | season = "Spring"; 36 | 37 | case "June": 38 | case "July": 39 | case "August": 40 | season = "Summer"; 41 | break; 42 | } 43 | console.log("Season is: ", season); 44 | 45 | // 3 46 | let day = prompt("What is the day today? ").toLowerCase(); 47 | if (day == "saturday" || day == "sunday") 48 | console.log(day, " is a weekend!") 49 | else console.log(day, " is a working day"); 50 | 51 | -------------------------------------------------------------------------------- /Day04_Conditionals/exerciseLevel3.js: -------------------------------------------------------------------------------- 1 | /** LEVEL 3 Challenges **/ 2 | let month = prompt("Enter a month: ").toLowerCase(); 3 | let daysCount; 4 | 5 | // check if it is leap year 6 | let d = new Date(); 7 | let year = d.getFullYear(); 8 | 9 | if (month == "february") { 10 | if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) { daysCount = 29; } 11 | else daysCount = 28; 12 | } else { 13 | switch(month){ 14 | case "january": 15 | case "march": 16 | case "may": 17 | case "july": 18 | case "august": 19 | case "october": 20 | case "december": 21 | daysCount = 31; 22 | break; 23 | 24 | case "april": 25 | case "june": 26 | case "september": 27 | case "november": 28 | daysCount = 30; 29 | break; 30 | } 31 | } 32 | console.log(month, " has ", daysCount, " days"); 33 | 34 | -------------------------------------------------------------------------------- /Day05_Arrays/level1.js: -------------------------------------------------------------------------------- 1 | /** LEVEL 1 Challenges **/ 2 | // 1 3 | let arr = []; 4 | // 2 5 | let arr2 = [1, 2, 3, 4, 5]; 6 | // 3 7 | let len = arr2.length; 8 | // 4 9 | let first = arr[0]; 10 | let midle = arr[parseInt(arr.length/2)]; 11 | let last = arr[arr.length - 1]; 12 | // 5 13 | const mixedDataTypes = ['bool', false, 1, 3.14, null, undefined, NaN]; 14 | // 6 15 | let itCompanies = ['Facebook', 'Google', 'Microsoft', 'Apple', 'IBM', 'Oracle', 'Amazon']; 16 | // 7 17 | console.log(itCompanies); 18 | // 8 19 | console.log(`There are ${itCompanies.length} IT Companies out there!`); 20 | // 9 21 | console.log(itCompanies[0]); 22 | console.log(itCompanies[parseInt(itCompanies.length/2)]); 23 | console.log(itCompanies[itCompanies.length-1]); 24 | // 10 25 | console.log(itCompanies[0]); 26 | console.log(itCompanies[1]); 27 | console.log(itCompanies[2]); 28 | console.log(itCompanies[3]); 29 | console.log(itCompanies[4]); 30 | console.log(itCompanies[5]); 31 | console.log(itCompanies[6]); 32 | // 11 33 | console.log(itCompanies[0].toUpperCase()); 34 | console.log(itCompanies[1].toUpperCase()); 35 | console.log(itCompanies[2].toUpperCase()); 36 | console.log(itCompanies[3].toUpperCase()); 37 | console.log(itCompanies[4].toUpperCase()); 38 | console.log(itCompanies[5].toUpperCase()); 39 | console.log(itCompanies[6].toUpperCase()); 40 | // 12: print like a sentence 41 | console.log(itCompanies.toString()); 42 | // 13 43 | if(itCompanies.includes('IBM')) { 44 | console.log("IBM exists!"); 45 | } else console.log("IBM does not exist"); 46 | 47 | // 14 48 | // 15 49 | console.log(itCompanies.sort()); 50 | // 16 51 | console.log(itCompanies.reverse()); 52 | // 17 53 | console.log(itCompanies.slice(0, 3)); 54 | // 18 : last 3 companies 55 | len = itCompanies.length 56 | let last3Companies = itCompanies.slice(len - 3, len); 57 | console.log("last", last3Companies); 58 | // 19 59 | let midCompany = itCompanies.slice(parseInt(itCompanies.length/2)); 60 | console.log(midCompany); 61 | // 20: remove the first IT company 62 | itCompanies.pop(); 63 | // 21: there are two companeis in the middel to be removed 64 | console.log(itCompanies); 65 | itCompanies.splice(parseInt(itCompanies.length/2)-1, 2); // IBM, GOOGLE gone! 66 | console.log(itCompanies); 67 | // 22 68 | itCompanies.splice(itCompanies.length-1, 1); 69 | console.log(itCompanies); 70 | // 23 71 | itCompanies.splice(0, itCompanies.length); 72 | console.log(itCompanies); 73 | 74 | /** LEVEL 1 Completed **/ 75 | -------------------------------------------------------------------------------- /Day05_Arrays/level2/countries.js: -------------------------------------------------------------------------------- 1 | const countries = [ 2 | 'Afghanistan', 3 | 'Albania', 4 | 'Algeria', 5 | 'Andorra', 6 | 'Angola', 7 | 'Antigua and Barbuda', 8 | 'Argentina', 9 | 'Armenia', 10 | 'Australia', 11 | 'Austria', 12 | 'Azerbaijan', 13 | 'Bahamas', 14 | 'Bahrain', 15 | 'Bangladesh', 16 | 'Barbados', 17 | 'Belarus', 18 | 'Belgium', 19 | 'Belize', 20 | 'Benin', 21 | 'Bhutan', 22 | 'Bolivia', 23 | 'Bosnia and Herzegovina', 24 | 'Botswana', 25 | 'Brazil', 26 | 'Brunei', 27 | 'Bulgaria', 28 | 'Burkina Faso', 29 | 'Burundi', 30 | 'Cambodia', 31 | 'Cameroon', 32 | 'Canada', 33 | 'Cape Verde', 34 | 'Central African Republic', 35 | 'Chad', 36 | 'Chile', 37 | 'China', 38 | 'Colombi', 39 | 'Comoros', 40 | 'Congo (Brazzaville)', 41 | 'Congo', 42 | 'Costa Rica', 43 | "Cote d'Ivoire", 44 | 'Croatia', 45 | 'Cuba', 46 | 'Cyprus', 47 | 'Czech Republic', 48 | 'Denmark', 49 | 'Djibouti', 50 | 'Dominica', 51 | 'Dominican Republic', 52 | 'East Timor (Timor Timur)', 53 | 'Ecuador', 54 | 'Egypt', 55 | 'El Salvador', 56 | 'Equatorial Guinea', 57 | 'Eritrea', 58 | 'Estonia', 59 | 'Ethiopia', 60 | 'Fiji', 61 | 'Finland', 62 | 'France', 63 | 'Gabon', 64 | 'Gambia, The', 65 | 'Georgia', 66 | 'Germany', 67 | 'Ghana', 68 | 'Greece', 69 | 'Grenada', 70 | 'Guatemala', 71 | 'Guinea', 72 | 'Guinea-Bissau', 73 | 'Guyana', 74 | 'Haiti', 75 | 'Honduras', 76 | 'Hungary', 77 | 'Iceland', 78 | 'India', 79 | 'Indonesia', 80 | 'Iran', 81 | 'Iraq', 82 | 'Ireland', 83 | 'Israel', 84 | 'Italy', 85 | 'Jamaica', 86 | 'Japan', 87 | 'Jordan', 88 | 'Kazakhstan', 89 | 'Kenya', 90 | 'Kiribati', 91 | 'Korea, North', 92 | 'Korea, South', 93 | 'Kuwait', 94 | 'Kyrgyzstan', 95 | 'Laos', 96 | 'Latvia', 97 | 'Lebanon', 98 | 'Lesotho', 99 | 'Liberia', 100 | 'Libya', 101 | 'Liechtenstein', 102 | 'Lithuania', 103 | 'Luxembourg', 104 | 'Macedonia', 105 | 'Madagascar', 106 | 'Malawi', 107 | 'Malaysia', 108 | 'Maldives', 109 | 'Mali', 110 | 'Malta', 111 | 'Marshall Islands', 112 | 'Mauritania', 113 | 'Mauritius', 114 | 'Mexico', 115 | 'Micronesia', 116 | 'Moldova', 117 | 'Monaco', 118 | 'Mongolia', 119 | 'Morocco', 120 | 'Mozambique', 121 | 'Myanmar', 122 | 'Namibia', 123 | 'Nauru', 124 | 'Nepal', 125 | 'Netherlands', 126 | 'New Zealand', 127 | 'Nicaragua', 128 | 'Niger', 129 | 'Nigeria', 130 | 'Norway', 131 | 'Oman', 132 | 'Pakistan', 133 | 'Palau', 134 | 'Panama', 135 | 'Papua New Guinea', 136 | 'Paraguay', 137 | 'Peru', 138 | 'Philippines', 139 | 'Poland', 140 | 'Portugal', 141 | 'Qatar', 142 | 'Romania', 143 | 'Russia', 144 | 'Rwanda', 145 | 'Saint Kitts and Nevis', 146 | 'Saint Lucia', 147 | 'Saint Vincent', 148 | 'Samoa', 149 | 'San Marino', 150 | 'Sao Tome and Principe', 151 | 'Saudi Arabia', 152 | 'Senegal', 153 | 'Serbia and Montenegro', 154 | 'Seychelles', 155 | 'Sierra Leone', 156 | 'Singapore', 157 | 'Slovakia', 158 | 'Slovenia', 159 | 'Solomon Islands', 160 | 'Somalia', 161 | 'South Africa', 162 | 'Spain', 163 | 'Sri Lanka', 164 | 'Sudan', 165 | 'Suriname', 166 | 'Swaziland', 167 | 'Sweden', 168 | 'Switzerland', 169 | 'Syria', 170 | 'Taiwan', 171 | 'Tajikistan', 172 | 'Tanzania', 173 | 'Thailand', 174 | 'Togo', 175 | 'Tonga', 176 | 'Trinidad and Tobago', 177 | 'Tunisia', 178 | 'Turkey', 179 | 'Turkmenistan', 180 | 'Tuvalu', 181 | 'Uganda', 182 | 'Ukraine', 183 | 'United Arab Emirates', 184 | 'United Kingdom', 185 | 'United States', 186 | 'Uruguay', 187 | 'Uzbekistan', 188 | 'Vanuatu', 189 | 'Vatican City', 190 | 'Venezuela', 191 | 'Vietnam', 192 | 'Yemen', 193 | 'Zambia', 194 | 'Zimbabwe' 195 | ] 196 | -------------------------------------------------------------------------------- /Day05_Arrays/level2/main.js: -------------------------------------------------------------------------------- 1 | /** LEVEL 2 Exercises **/ 2 | // 2 3 | let text = 'I love teaching and empowering people. I teach HTML, CSS, JS, REACT, PYTHON.' 4 | let arr = text.split(/[,\s]+|[\s]/); 5 | console.log(arr); 6 | // 3 7 | // i 8 | const shoppingCart = ['Milk', 'Coffee', 'Tea', 'Honey']; 9 | // ii 10 | shoppingCart.unshift('Meat'); 11 | // iii 12 | shoppingCart.push("Sugar"); 13 | // iv 14 | shoppingCart.splice(shoppingCart.lastIndexOf('Honey'), 1); 15 | // v 16 | shoppingCart[shoppingCart.indexOf('Tea')] = "Green Tea"; 17 | console.log(shoppingCart); 18 | // 4 19 | if (countries.indexOf("Ethiopia")) { 20 | console.log("ETHIOPIA"); 21 | } else countries.push("Ethiopia"); 22 | // 5 23 | if (webTechs.indexOf("Sass")) { 24 | console.log("Sass is a CSS preprocess"); 25 | } else webTechs.push("Sass"); 26 | console.log(webTechs); 27 | // 6 28 | const frontEnd = ['HTML', 'CSS', 'JS', 'React', 'Redux']; 29 | const backEnd = ['Node', 'Express', 'MangoDB']; 30 | const fullStack = frontEnd.concat(backEnd); 31 | console.log(fullStack); 32 | 33 | // ** Level 2 completed **/ 34 | -------------------------------------------------------------------------------- /Day05_Arrays/level2/web_techs.js: -------------------------------------------------------------------------------- 1 | const webTechs = [ 2 | 'HTML', 3 | 'CSS', 4 | 'JavaScript', 5 | 'React', 6 | 'Redux', 7 | 'Node', 8 | 'MangoDB' 9 | ]; 10 | -------------------------------------------------------------------------------- /Day05_Arrays/level3.js: -------------------------------------------------------------------------------- 1 | /** LEVEL 3 challenges for Day 5: Arrays **/ 2 | // 1 3 | const ages = [19, 22, 19, 24, 20, 25, 26, 24, 25, 24]; 4 | // i 5 | ages.sort(); 6 | console.log(ages); 7 | const min = ages[0]; 8 | const max = ages[ages.length-1]; 9 | // ii 10 | let len = ages.length; 11 | let median = (ages[parseInt(len/2)-1] + ages[parseInt(len/2)])/2; 12 | // iii 13 | const average = (ages[0]+ages[1]+ages[2]+ages[3]+ages[4]+ages[5]+ages[6]+ages[7]+ages[8]+ages[9])/len; 14 | 15 | console.log(average); 16 | // iv 17 | let range = max - min; 18 | console.log("Range of ages: ", range); 19 | // v 20 | Math.abs(min-average) < Math.abs(max-average) ? console.log("Data is left skewed"): console.log('Data is right skewed!'); 21 | // vi 22 | let first10Countries = countries.slice(0, 10); 23 | console.log(first10Countries); 24 | // 2 : Find the mid countries 25 | if (countries.length % 2 === 0){ 26 | let firstMid = (countries.length)/2 -1; 27 | let secondMid = (countries.length)/2; 28 | console.log(countries[firstMid], countries[secondMid]); 29 | } else console.log(countries[parseInt(countries.length/2)-1]); // Lebanon 30 | 31 | // 3: convert in to equal halves 32 | // remove first country to make the arr even 33 | countries.shift(); 34 | // now convert into equal halves 35 | console.log(countries); 36 | let firstHalf = countries.splice(0,countries.length/2); 37 | let anotherHalf = countries.splice(0, countries.length); 38 | console.log(anotherHalf); 39 | 40 | //** LEVEL 3 Completed **/ 41 | -------------------------------------------------------------------------------- /Day06_Loops/exerciseLevel1.js: -------------------------------------------------------------------------------- 1 | /** LEVEL 1 Challenges, day 6 LOOPS **/ 2 | // 1(a) FOR LOOP 3 | /** 4 | for(let i = 0;i < 11; i++) { 5 | console.log(i); 6 | } 7 | // 1(b) WHILE LOOP 8 | let i = 0; 9 | while (i < 11) { 10 | console.log(i); 11 | i++; 12 | } 13 | // 1(c) DO WHILE LOOP 14 | let x = 0; 15 | do { 16 | console.log(x); 17 | x++; 18 | } while (x < 11); 19 | // 2(a) FOR LOOP 20 | for (let i = 10; i > -1; i--) { 21 | console.log(i); 22 | } 23 | // 2(b) WHILE LOOP 24 | let i = 10; 25 | while (i > -1) { 26 | console.log(i); 27 | i--; 28 | } 29 | // 2(c) DO WHILE LOOP 30 | let x = 10; 31 | do { 32 | console.log(x); 33 | x--; 34 | } while (x > -1);**/ 35 | // 3, iterate o - n using for loop 36 | let n = 3; 37 | for (let i = 0; i <= n; i++) { 38 | console.log(i); 39 | } 40 | // 4 make the hashes pattern 41 | for(i = 1; i <= 7; i++) { 42 | console.log("#".repeat(i)); 43 | } 44 | // 5 45 | for(let i = 0; i < 11; i++) { 46 | console.log(`${i} x ${i} = ${i*i}`); 47 | } 48 | // 6 49 | console.log("i\ti^2\ti^3"); 50 | for(let i = 0; i < 11; i++) { 51 | console.log(`${i}\t${i**2}\t${i**3}`); 52 | } 53 | // 7 54 | for(let i = 0; i < 101; i += 2) { 55 | console.log(i); 56 | } 57 | // 8 58 | for (let i = 1; i < 101; i += 2) { 59 | console.log(i); 60 | } 61 | // 9 : PRIME NUMBERS 62 | // 10 63 | let sum = 0; 64 | for(let i = 0; i < 101; i++) { 65 | sum += i; 66 | } console.log("Sum of 0-100: ", sum); 67 | // 11 68 | let sumEven = 0; 69 | let sumOdd = 0; 70 | for (let i = 0; i < 101; i++) { 71 | if (i%2==0) sumEven += i; 72 | else sumOdd += i; 73 | } console.log(sumEven, sumOdd); 74 | // 12 : same as above but sol should be in array format 75 | console.log([sumEven, sumOdd]); 76 | // 13 77 | let randomNums = []; 78 | for (let i = 0; i < 5; i++) { 79 | randomNums.push(parseInt(Math.PI * Math.random() * 100 + 3)); 80 | } 81 | console.log(randomNums); 82 | // 14 Numbers mush be unique 83 | let randomNumbers = []; 84 | for (let i = 0; i < 5; i++) { 85 | let randNum = parseInt(Math.PI * Math.random() * 100 + i) 86 | if(randomNumbers.indexOf(randNum) == -1) { 87 | randomNumbers.push(randNum); 88 | } 89 | } 90 | console.log(randomNumbers); 91 | // 15 92 | let alphabets = 'abcdefghijklmnopqrstuvwxyz'; 93 | let randoms = []; 94 | for(let i = 0; i < 6; i++) { 95 | if(i%2 == 0) randoms.push(i); 96 | else randoms.push(alphabets[parseInt(Math.random() * 25)]) 97 | } 98 | console.log(randoms.join('')); 99 | 100 | /** LEVEL 1 FINISHED **/ 101 | -------------------------------------------------------------------------------- /Day06_Loops/exerciseLevel2/countries.js: -------------------------------------------------------------------------------- 1 | const countries = [ 2 | 'Afghanistan', 3 | 'Albania', 4 | 'Algeria', 5 | 'Andorra', 6 | 'Angola', 7 | 'Antigua and Barbuda', 8 | 'Argentina', 9 | 'Armenia', 10 | 'Australia', 11 | 'Austria', 12 | 'Azerbaijan', 13 | 'Bahamas', 14 | 'Bahrain', 15 | 'Bangladesh', 16 | 'Barbados', 17 | 'Belarus', 18 | 'Belgium', 19 | 'Belize', 20 | 'Benin', 21 | 'Bhutan', 22 | 'Bolivia', 23 | 'Bosnia and Herzegovina', 24 | 'Botswana', 25 | 'Brazil', 26 | 'Brunei', 27 | 'Bulgaria', 28 | 'Burkina Faso', 29 | 'Burundi', 30 | 'Cambodia', 31 | 'Cameroon', 32 | 'Canada', 33 | 'Cape Verde', 34 | 'Central African Republic', 35 | 'Chad', 36 | 'Chile', 37 | 'China', 38 | 'Colombi', 39 | 'Comoros', 40 | 'Congo (Brazzaville)', 41 | 'Congo', 42 | 'Costa Rica', 43 | "Cote d'Ivoire", 44 | 'Croatia', 45 | 'Cuba', 46 | 'Cyprus', 47 | 'Czech Republic', 48 | 'Denmark', 49 | 'Djibouti', 50 | 'Dominica', 51 | 'Dominican Republic', 52 | 'East Timor (Timor Timur)', 53 | 'Ecuador', 54 | 'Egypt', 55 | 'El Salvador', 56 | 'Equatorial Guinea', 57 | 'Eritrea', 58 | 'Estonia', 59 | 'Ethiopia', 60 | 'Fiji', 61 | 'Finland', 62 | 'France', 63 | 'Gabon', 64 | 'Gambia, The', 65 | 'Georgia', 66 | 'Germany', 67 | 'Ghana', 68 | 'Greece', 69 | 'Grenada', 70 | 'Guatemala', 71 | 'Guinea', 72 | 'Guinea-Bissau', 73 | 'Guyana', 74 | 'Haiti', 75 | 'Honduras', 76 | 'Hungary', 77 | 'Iceland', 78 | 'India', 79 | 'Indonesia', 80 | 'Iran', 81 | 'Iraq', 82 | 'Ireland', 83 | 'Israel', 84 | 'Italy', 85 | 'Jamaica', 86 | 'Japan', 87 | 'Jordan', 88 | 'Kazakhstan', 89 | 'Kenya', 90 | 'Kiribati', 91 | 'Korea, North', 92 | 'Korea, South', 93 | 'Kuwait', 94 | 'Kyrgyzstan', 95 | 'Laos', 96 | 'Latvia', 97 | 'Lebanon', 98 | 'Lesotho', 99 | 'Liberia', 100 | 'Libya', 101 | 'Liechtenstein', 102 | 'Lithuania', 103 | 'Luxembourg', 104 | 'Macedonia', 105 | 'Madagascar', 106 | 'Malawi', 107 | 'Malaysia', 108 | 'Maldives', 109 | 'Mali', 110 | 'Malta', 111 | 'Marshall Islands', 112 | 'Mauritania', 113 | 'Mauritius', 114 | 'Mexico', 115 | 'Micronesia', 116 | 'Moldova', 117 | 'Monaco', 118 | 'Mongolia', 119 | 'Morocco', 120 | 'Mozambique', 121 | 'Myanmar', 122 | 'Namibia', 123 | 'Nauru', 124 | 'Nepal', 125 | 'Netherlands', 126 | 'New Zealand', 127 | 'Nicaragua', 128 | 'Niger', 129 | 'Nigeria', 130 | 'Norway', 131 | 'Oman', 132 | 'Pakistan', 133 | 'Palau', 134 | 'Panama', 135 | 'Papua New Guinea', 136 | 'Paraguay', 137 | 'Peru', 138 | 'Philippines', 139 | 'Poland', 140 | 'Portugal', 141 | 'Qatar', 142 | 'Romania', 143 | 'Russia', 144 | 'Rwanda', 145 | 'Saint Kitts and Nevis', 146 | 'Saint Lucia', 147 | 'Saint Vincent', 148 | 'Samoa', 149 | 'San Marino', 150 | 'Sao Tome and Principe', 151 | 'Saudi Arabia', 152 | 'Senegal', 153 | 'Serbia and Montenegro', 154 | 'Seychelles', 155 | 'Sierra Leone', 156 | 'Singapore', 157 | 'Slovakia', 158 | 'Slovenia', 159 | 'Solomon Islands', 160 | 'Somalia', 161 | 'South Africa', 162 | 'Spain', 163 | 'Sri Lanka', 164 | 'Sudan', 165 | 'Suriname', 166 | 'Swaziland', 167 | 'Sweden', 168 | 'Switzerland', 169 | 'Syria', 170 | 'Taiwan', 171 | 'Tajikistan', 172 | 'Tanzania', 173 | 'Thailand', 174 | 'Togo', 175 | 'Tonga', 176 | 'Trinidad and Tobago', 177 | 'Tunisia', 178 | 'Turkey', 179 | 'Turkmenistan', 180 | 'Tuvalu', 181 | 'Uganda', 182 | 'Ukraine', 183 | 'United Arab Emirates', 184 | 'United Kingdom', 185 | 'United States', 186 | 'Uruguay', 187 | 'Uzbekistan', 188 | 'Vanuatu', 189 | 'Vatican City', 190 | 'Venezuela', 191 | 'Vietnam', 192 | 'Yemen', 193 | 'Zambia', 194 | 'Zimbabwe' 195 | ] 196 | -------------------------------------------------------------------------------- /Day06_Loops/exerciseLevel2/master.js: -------------------------------------------------------------------------------- 1 | /** LEVEL 2 Challenges **/ 2 | let alphanums = '123456789abcdefghijklmnopqrstuvwxyz123456789'; 3 | let n = parseInt(Math.random() * alphanums.length) % 16; // max can be 16 4 | let rands = []; 5 | for(let i = 0; i <= n; i++) { 6 | rands.push(alphanums[Math.floor(Math.random() * alphanums.length) -1]); 7 | } console.log(rands.join("")); 8 | 9 | // 2: generate a hexadec number 10 | let allHexCodes = '123456789abcdef'; 11 | let hexChars = []; 12 | for(let i=0; i<6; i++) { 13 | hexChars.push(allHexCodes[parseInt(Math.random()*allHexCodes.length)-1]); 14 | } console.log('#' + hexChars.join('')); 15 | // 3 : generate an rgb color 16 | let rgb = []; 17 | for(const char of '123') { 18 | var red = (parseInt(Math.random() * 255)); 19 | var grn = (parseInt(Math.random() * 255)); 20 | var blu = (parseInt(Math.random() * 255)); 21 | 22 | rgb.push(red, grn, blu); 23 | } console.log(`rgb(${red}, ${grn}, ${blu})`); 24 | 25 | // 4: Gonna use for of loop here 26 | let capCountries = []; 27 | for(const country of countries) { 28 | capCountries.push(country.toUpperCase()); 29 | } console.log(capCountries); 30 | 31 | // 5 32 | let countryNameLens = []; 33 | for(const country of countries) { 34 | countryNameLens.push(country.length); 35 | } console.log(countryNameLens); 36 | 37 | // 6: array of arrays 38 | let countryData = []; 39 | for(const country of countries) { 40 | let len = country.length; 41 | let first3Chars = country.slice(0, 3).toUpperCase(); 42 | countryData.push([country, first3Chars, len]); 43 | } 44 | for (const arr of countryData) { 45 | console.log(arr); 46 | } 47 | // 7 48 | let noCountry = true; 49 | let landCountriesList = []; 50 | 51 | for(const i of countries) { 52 | if(i.includes('land')) { 53 | landCountriesList.push(i); 54 | noCountry = false; 55 | } 56 | } 57 | if(noCountry) { 58 | console.log("All these countries are without land"); 59 | } else { 60 | for(const country of landCountriesList) 61 | console.log(country); 62 | } 63 | 64 | // 8 65 | let endsWith_ia = []; 66 | for (const country of countries) { 67 | if(country.endsWith('ia')) 68 | endsWith_ia.push(country); 69 | } 70 | if(endsWith_ia.length > 0) { 71 | for(const each of endsWith_ia) 72 | console.log(each); 73 | } 74 | 75 | // 9 76 | let maxLength = 0; 77 | let maxLenCountry; 78 | for (const country of countries) { 79 | if(country.length > maxLength) { 80 | maxLength = country.length; 81 | maxLenCountry = country; 82 | } 83 | } console.log(maxLenCountry); 84 | 85 | // 10 86 | let lenFiveCountries = []; 87 | for (const country of countries) { 88 | if (country.length === 5) 89 | lenFiveCountries.push(country); 90 | } 91 | console.log(lenFiveCountries); 92 | 93 | // 11 94 | let length = webTechs[0].length; 95 | let word; 96 | for(const tech of webTechs) { 97 | if (tech.length > length) { 98 | word = tech; 99 | length = tech.length; 100 | } 101 | } console.log(word); 102 | 103 | // 12 104 | let techWithLen = []; 105 | for (const tech of webTechs) { 106 | let len = tech.length; 107 | let caps = tech.toUpperCase(); 108 | 109 | techWithLen.push([caps, len]) 110 | }; 111 | console.log(techWithLen); 112 | 113 | // 13: create the MERN stack 114 | let mernArray = ['MongoDB', 'Express', 'React', 'Node']; 115 | let mernStack = []; 116 | 117 | for (const tech of mernArray) { 118 | mernStack.push(tech[0]); 119 | }; console.log(mernStack.join('')); 120 | 121 | // 14 122 | for(const tech of webTechs) { 123 | console.log(tech); 124 | } 125 | 126 | // 15 127 | let fruits = ['banana', 'orange', 'mango', 'lemon']; 128 | let reversedFruits = []; 129 | 130 | for (let i = fruits.length-1; i >= 0; i--) { 131 | reversedFruits.push(fruits[i]); 132 | } console.log(reversedFruits); 133 | 134 | // 16 print the webTechs 135 | for (const each of webTechs) { 136 | console.log(each); 137 | } 138 | 139 | 140 | // ** LEVEL 2 Challenge completed ** // 141 | // NOTE: the files web_techs.js and countries.js are required to properly interpret this file 142 | -------------------------------------------------------------------------------- /Day06_Loops/exerciseLevel2/web_techs.js: -------------------------------------------------------------------------------- 1 | const webTechs = [ 2 | 'HTML', 3 | 'CSS', 4 | 'JavaScript', 5 | 'React', 6 | 'Redux', 7 | 'Node', 8 | 'MangoDB' 9 | ]; 10 | -------------------------------------------------------------------------------- /Day06_Loops/exerciseLevel3.js: -------------------------------------------------------------------------------- 1 | /** LEVEL 3 Challenges **/ 2 | // 1 3 | let countriesCopy = []; 4 | for (const country of countries) { 5 | countriesCopy.push(country); 6 | } // copied without mutation 7 | 8 | // 2: sort the copied Array 9 | let sortedCountries = countriesCopy.sort(); 10 | console.log(sortedCountries); 11 | 12 | // 3 13 | let sortedWebTechs = webTechs.sort(); 14 | let mernStack = ['MangoDB', 'Express', 'Redux', 'NodeJS']; 15 | let sortedMernStack = mernStack.sort(); 16 | 17 | // 4 18 | let landCountries = []; 19 | for(const country of countries) { 20 | if(country.includes('land')) { 21 | landCountries.push(country); 22 | } 23 | } console.log(landCountries); 24 | 25 | // 5 26 | let maxLength = 0; 27 | let maxLenCountry; 28 | for (const country of countries) { 29 | if(country.length > maxLength) { 30 | maxLength = country.length; 31 | maxLenCountry = country; 32 | } 33 | } console.log(maxLenCountry); // central african republic 34 | 35 | // 6: same as 4 36 | // 7 37 | let lenFourCountries = []; 38 | for (const country of countries) { 39 | if(country.length === 4) 40 | lenFourCountries.push(country); 41 | } console.log(lenFourCountries); 42 | 43 | // 8 44 | let twoWordCountries = []; 45 | for(const country of countries) { 46 | if(country.split(' ').length > 1) 47 | twoWordCountries.push(country); 48 | } console.log(twoWordCountries); 49 | 50 | // 9 51 | let reversedCountries = countries.reverse(); 52 | let capReverseCountries = []; 53 | 54 | for(const country of reversedCountries) { 55 | capReverseCountries.push(country.toUpperCase()); 56 | } console.log(capReverseCountries); 57 | 58 | //** Challenge 3 completed **/ 59 | -------------------------------------------------------------------------------- /Day07_Functions/level1.js: -------------------------------------------------------------------------------- 1 | // LEVEL 1 Challenges // 2 | // 1 3 | function fullName() { 4 | console.log("Hamza Mateen"); 5 | } fullName(); 6 | 7 | // 2 8 | function fullName1(firstName, lastName) { 9 | console.log(firstName + ' ' + lastName); 10 | } fullName1("Hamza", "Mateen"); 11 | 12 | // 3 13 | function addNumbers(a, b) { 14 | return a + b; 15 | } console.log(addNumbers(10, 20)); 16 | 17 | // 4 18 | function areaOfRectangle(l, w) { 19 | return l*w; 20 | } console.log(areaOfRectangle(1,2)); 21 | 22 | // 5 23 | function perimeterOfRectangle(l, w) { 24 | return 2*(l+w); 25 | } perimeterOfRectangle(2, 34); 26 | 27 | // 6 28 | function volumeOfRectPrism(l, w, h) { 29 | return l*w*h; 30 | } volumeOfRectPrism(2, 3, 4); 31 | 32 | // 7 33 | function areaOfCircle(r) { 34 | return Math.PI * r ** 2; 35 | } areaOfCircle(2); 36 | 37 | // 8 38 | function circumOfCircle(r) { 39 | return Math.PI * 2 * r; 40 | } circumOfCircle(3); 41 | 42 | // 9 43 | function densityOfSubstance (m, v) { 44 | return m/v; 45 | } densityOfSubstance(23, 3); 46 | 47 | // 10 48 | function calcSpeed(d, t) { 49 | return d/t; 50 | } 51 | 52 | // 11 53 | function calcWeight(m) { 54 | return Math.PI ** 2 * m; 55 | } // impressive ;) 56 | 57 | // 12 58 | function celciusToFahrenheit(c) { 59 | return (c * (9/5)) + 32; 60 | } celciusToFahrenheit(37); 61 | 62 | // 13: BMI Calculator 63 | function calcBMI(w, h) { 64 | return w/(h*h); 65 | } 66 | let BMI = calcBMI(66, 1.78); 67 | if (BMI < 18.5) console.log("Underweight"); 68 | else if (BMI < 24.9) 69 | console.log("Normal Weight"); 70 | else if (BMI < 29.9) { 71 | console.log("Overweight"); 72 | } else { 73 | console.log("OBESE!") 74 | }; 75 | 76 | // 14 77 | function checkSeason(month) { 78 | let season; 79 | 80 | switch (month.toLowerCase()) { 81 | case "september": 82 | case "october": 83 | case "november": 84 | season = "Autumn"; 85 | break; 86 | 87 | case "december": 88 | case "january": 89 | case "february": 90 | season = "Winter"; 91 | break; 92 | 93 | case "march": 94 | case "april": 95 | case "may": 96 | season = "Spring"; 97 | 98 | case "june": 99 | case "july": 100 | case "august": 101 | season = "Summer"; 102 | break; 103 | } 104 | return season; 105 | } console.log(checkSeason("DecEMBer")); 106 | 107 | // 15 108 | function findMax(a, b, c) { 109 | let max = 0; 110 | for(const elem of arguments) { 111 | if (elem > max) max = elem; 112 | } return max; 113 | } console.log(findMax(2, 34, 4)); 114 | 115 | // LEVEL 1 Finished! 116 | -------------------------------------------------------------------------------- /Day07_Functions/level2.js: -------------------------------------------------------------------------------- 1 | /** LEVEL 2 Challenges Functions **/ 2 | 3 | // 2: solve quardratic equation 4 | let solveQuadEquation = function(a, b, c) { 5 | let disc = Math.pow(b, 2) - 4*a*c; 6 | 7 | let posX = (-b+Math.pow(disc, 0.5))/(2*a); 8 | let negX = (-b-Math.pow(disc, 0.5))/(2*a); 9 | 10 | return [posX, negX]; // can be NaN 11 | } 12 | console.log(solveQuadEquation(1, 2, 3)); 13 | 14 | // 3 15 | let printArray = function(arr) { 16 | for(const value of arr) { 17 | console.log(value); 18 | } 19 | } 20 | printArray(Array(3).fill(3)); 21 | 22 | // 4 23 | let showDateTime = () => { 24 | let d = new Date(); 25 | 26 | let date = d.getDate(); 27 | let month = d.getMonth(); 28 | let year = d.getFullYear(); 29 | let hour = d.getHours(); 30 | let mins = d.getMinutes(); 31 | 32 | date = date < 10 ? '0' + date.toString(): date; 33 | month = month < 10 ? '0' + month.toString 34 | (): month; 35 | hour = hour < 10 ? '0' + hour.toString 36 | (): hour; 37 | mins = mins < 10 ? '0' + mins.toString(): mins; 38 | 39 | let format = `${date}/${month}/${year} ${hour}:${mins}`; 40 | 41 | return format; 42 | } 43 | // 5 44 | function swapValues(a, b) { 45 | return [b, a]; 46 | } 47 | let x = 1; 48 | let y = 2; 49 | console.log(swapValues(x, y)); 50 | 51 | // 6 52 | let reverseArray = (arr) { 53 | let reversed = []; 54 | for(let i = arr.length-1; i >= 0; i--) 55 | reversed.push(i); 56 | 57 | return reversed; 58 | } 59 | 60 | // 7 61 | let capitalizeArray = (arr) => { 62 | let caps = []; 63 | for(const item of arr) { 64 | caps.push(item.toUpperCase()); 65 | } 66 | 67 | return caps; 68 | } 69 | 70 | // 8 71 | let addItem = (arr, item) => { 72 | return arr.push(item); 73 | } 74 | 75 | // 9 76 | let removeItem = (arr, index) => { 77 | arr.splice(index, 1); 78 | return arr; 79 | } 80 | 81 | // 10 82 | function addUpto(num) { 83 | if(num == 0) return 0; 84 | else return num + addUpto(num-1); 85 | } 86 | 87 | // 11 88 | function addOddsUpto(num) { 89 | if(num <= 0) return 0; 90 | num = num%2== 0? num -1: num; 91 | return num + addOddsUpto(num - 2); 92 | } 93 | 94 | // 12 95 | function addEvensUpto(num) { 96 | if(num <= 0) return 0; 97 | num = num%2== 0? num: num-1; 98 | return num + addOddsUpto(num - 2); 99 | } 100 | 101 | // 14 102 | let sumOfNums = (...args) => { 103 | let sum = 0; 104 | for(const x of args) { 105 | sum += x; 106 | } 107 | return sum; 108 | } 109 | 110 | // 15 111 | function generateIP () { 112 | let a = parseInt(Math.random() * 255); 113 | let b = parseInt(Math.random() * 255); 114 | let c = parseInt(Math.random() * 255); 115 | let d = parseInt(Math.random() * 255); 116 | 117 | 118 | return `${a}.${b}.${c}.${d}`; 119 | } 120 | 121 | // 16 122 | function macAddGenerator () { 123 | let arr = []; 124 | let alphanums = '0123456789ABCDEF'; 125 | 126 | for(let i = 1; i <= 6; i++) { 127 | let id1 = Math.ceil(Math.random() * 15); 128 | let id2 = Math.ceil(Math.random() * 15); 129 | 130 | arr.push(alphanums[id1] + alphanums[id2]); 131 | } 132 | 133 | return arr.join(':'); 134 | } 135 | // 17 random hex number gen 136 | function randomHexaNumberGenerator() { 137 | let literal = '0123456789ABCDEF'; 138 | 139 | let hex = []; 140 | let len = Math.floor(Math.random() * 11); 141 | for(let i=0; i < len; i++) { 142 | let index= Math.ceil(Math.random() * literal.length) -1; 143 | hex.push(literal[index]); 144 | } 145 | 146 | return '#' + hex.join(''); 147 | } 148 | // 18 149 | function randomUserIdGenerator() { 150 | let literal = `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`; 151 | let id = []; 152 | for(let x=0; x<7; x++) { 153 | let index = Math.ceil(Math.random() * literal.length)-1; 154 | id.push(literal[index]) 155 | } 156 | return id.join(''); 157 | } 158 | 159 | 160 | -------------------------------------------------------------------------------- /Day07_Functions/level3.js: -------------------------------------------------------------------------------- 1 | // LEVEL 3 Challenges Functions ** / 2 | let userIdGeneratedByUser = () => { 3 | let len = parseInt(prompt("Enter length of ID: ")); 4 | let idCount = parseInt(prompt("Enter no of IDs: ")); 5 | let alphanums = '123456789abcdefghijklmnopqrstuvwxyz123456789'; 6 | 7 | let allID = []; 8 | for(let x=1; x<=idCount; x++) { 9 | let rands = []; 10 | for (let i = 1; i <= len; i++) { 11 | rands.push(alphanums[Math.floor(Math.random() * alphanums.length) - 1]); 12 | } 13 | allID.push(rands.join('')); 14 | } 15 | return allID; 16 | } 17 | console.log(userIdGeneratedByUser()); 18 | 19 | // 2 20 | let rgbColorGenerator = () => { 21 | let rgb = []; 22 | for (const char of '111') { 23 | var red = (parseInt(Math.random() * 255)); 24 | var grn = (parseInt(Math.random() * 255)); 25 | var blu = (parseInt(Math.random() * 255)); 26 | rgb.push(red, grn, blu); 27 | } 28 | return `rgb(${red}, ${grn}, ${blu})`; 29 | } 30 | console.log(rgbColorGenerator()); 31 | 32 | // 3 33 | let arrayOfHexaColors = () => { 34 | let allHexCodes = '123456789abcdef'; 35 | let loopCount = parseInt(Math.random() * 10); 36 | let hexColorArr = []; 37 | 38 | for(let x=1; x<=loopCount; x++) { 39 | let hexChars = []; 40 | for (let i = 0; i < 6; i++) { 41 | hexChars.push(allHexCodes[parseInt(Math.random() * allHexCodes.length) - 1]); 42 | } 43 | hexColorArr.push('#' + hexChars.join('')); 44 | } 45 | return hexColorArr; 46 | } 47 | console.log(arrayOfHexaColors()); 48 | 49 | // 4 50 | // 8 51 | let shuffleArray = (arr) => { 52 | // develop the shuffle algorigthm 53 | let len = arr.length; 54 | let uniqueRands = []; 55 | 56 | while(uniqueRands.length != len) { 57 | let randomNum = parseInt(Math.random() * len); 58 | if(uniqueRands.indexOf(randomNum) === -1) uniqueRands.push(randomNum); 59 | } // developed; 60 | 61 | let randomizedArr = []; 62 | for(const index of uniqueRands) { 63 | randomizedArr.push(arr[index]); 64 | } 65 | return randomizedArr; 66 | } 67 | let arr = [1, 23, 34, 32, 2, 1]; 68 | console.log(shuffleArray(arr)); 69 | 70 | // 9 71 | function factorial(num) { 72 | if (num <= 1) return 1; 73 | else return num * factorial(num-1); 74 | } 75 | console.log(factorial(5)); 76 | 77 | // 10 78 | let isEmpty = (arg) => !Boolean(arg.length); 79 | console.log(isEmpty(Array())); 80 | 81 | // 11 82 | let sum = (...args) => { 83 | let total = 0; 84 | for(const elem of args) total += elem; 85 | return total; 86 | } 87 | console.log(sum(2, 34, 23)); 88 | 89 | // 12 90 | let sumOfArrayItems = (arr) => { 91 | let sum = 0; 92 | for(const i of arr) 93 | sum += i 94 | return sum; 95 | } 96 | 97 | // 13 98 | let average = (arr) => { 99 | return sumOfArrayItems(arr) / arr.length; 100 | } 101 | 102 | // 14 103 | let modifyArray = arr => { 104 | if(arr.length < 5) return 'Item Not Found!'; 105 | arr[4] = arr[4].toUpperCase(); 106 | return arr; 107 | } 108 | 109 | // 15 110 | let isPrime = num => { 111 | if(num <= 0 || num == 1) return false; 112 | if(num == 2 || num == 3) return true; 113 | 114 | for(let i=1; i<=Math.sqrt(num); i++) { 115 | if(num % i == 0) return false; 116 | } 117 | return true; 118 | } 119 | 120 | // 16 121 | function areAllUnique(arr) { 122 | for(let x = 1; x < arr.length; x++) { 123 | for(let i = 0; i< x; i++) { 124 | if(arr[x] == arr[i]) 125 | return false; 126 | } 127 | } return true; 128 | } 129 | 130 | // 17 of smae type 131 | let areSameType = arr => { 132 | let type = typeof arr[0]; 133 | for(const i of arr) { 134 | if(type != i) 135 | return false; 136 | } 137 | return true; 138 | } 139 | 140 | // 18 141 | function isValidVariable(varName) { 142 | let regex = /[_|\$|a-z|A-Z|0-9]+/; 143 | return regex.test(varName); 144 | } 145 | // 19 146 | let getUniqueRands = () => { 147 | let arr = []; 148 | for(let i = 0; i<7; i++) { 149 | let random = Math.ceil(Math.random() * 9); 150 | 151 | let isUnique = true; 152 | for(const x of arr) { 153 | if(random == x) { 154 | isUnique = false; 155 | break; 156 | } 157 | } 158 | if(isUnique) arr.push(random); 159 | } 160 | return arr; 161 | } 162 | 163 | // 20 164 | function reverseCountries (arr) { 165 | let copy = arr.slice(0, arr.length); 166 | 167 | let index = 0; 168 | for(let i=arr.length-1; i>=0; i--) { 169 | arr[index] = copy[i]; 170 | index++; 171 | } 172 | return arr; 173 | } 174 | // Challenge 3 Completed 175 | -------------------------------------------------------------------------------- /Day08_Objects/countries.js: -------------------------------------------------------------------------------- 1 | const countries = [ 2 | { 3 | name: 'Afghanistan', 4 | capital: 'Kabul', 5 | languages: ['Pashto', 'Uzbek', 'Turkmen'], 6 | population: 27657145, 7 | flag: 'https://restcountries.eu/data/afg.svg', 8 | currency: 'Afghan afghani' 9 | }, 10 | { 11 | name: 'Åland Islands', 12 | capital: 'Mariehamn', 13 | languages: ['Swedish'], 14 | population: 28875, 15 | flag: 'https://restcountries.eu/data/ala.svg', 16 | currency: 'Euro' 17 | }, 18 | { 19 | name: 'Albania', 20 | capital: 'Tirana', 21 | languages: ['Albanian'], 22 | population: 2886026, 23 | flag: 'https://restcountries.eu/data/alb.svg', 24 | currency: 'Albanian lek' 25 | }, 26 | { 27 | name: 'Algeria', 28 | capital: 'Algiers', 29 | languages: ['Arabic'], 30 | population: 40400000, 31 | flag: 'https://restcountries.eu/data/dza.svg', 32 | currency: 'Algerian dinar' 33 | }, 34 | { 35 | name: 'American Samoa', 36 | capital: 'Pago Pago', 37 | languages: ['English', 'Samoan'], 38 | population: 57100, 39 | flag: 'https://restcountries.eu/data/asm.svg', 40 | currency: 'United State Dollar' 41 | }, 42 | { 43 | name: 'Andorra', 44 | capital: 'Andorra la Vella', 45 | languages: ['Catalan'], 46 | population: 78014, 47 | flag: 'https://restcountries.eu/data/and.svg', 48 | currency: 'Euro' 49 | }, 50 | { 51 | name: 'Angola', 52 | capital: 'Luanda', 53 | languages: ['Portuguese'], 54 | population: 25868000, 55 | flag: 'https://restcountries.eu/data/ago.svg', 56 | currency: 'Angolan kwanza' 57 | }, 58 | { 59 | name: 'Anguilla', 60 | capital: 'The Valley', 61 | languages: ['English'], 62 | population: 13452, 63 | flag: 'https://restcountries.eu/data/aia.svg', 64 | currency: 'East Caribbean dollar' 65 | }, 66 | { 67 | name: 'Antarctica', 68 | capital: '', 69 | languages: ['English', 'Russian'], 70 | population: 1000, 71 | flag: 'https://restcountries.eu/data/ata.svg', 72 | currency: 'Australian dollar' 73 | }, 74 | { 75 | name: 'Antigua and Barbuda', 76 | capital: "Saint John's", 77 | languages: ['English'], 78 | population: 86295, 79 | flag: 'https://restcountries.eu/data/atg.svg', 80 | currency: 'East Caribbean dollar' 81 | }, 82 | { 83 | name: 'Argentina', 84 | capital: 'Buenos Aires', 85 | languages: ['Spanish', 'Guaraní'], 86 | population: 43590400, 87 | flag: 'https://restcountries.eu/data/arg.svg', 88 | currency: 'Argentine peso' 89 | }, 90 | { 91 | name: 'Armenia', 92 | capital: 'Yerevan', 93 | languages: ['Armenian', 'Russian'], 94 | population: 2994400, 95 | flag: 'https://restcountries.eu/data/arm.svg', 96 | currency: 'Armenian dram' 97 | }, 98 | { 99 | name: 'Aruba', 100 | capital: 'Oranjestad', 101 | languages: ['Dutch', '(Eastern) Punjabi'], 102 | population: 107394, 103 | flag: 'https://restcountries.eu/data/abw.svg', 104 | currency: 'Aruban florin' 105 | }, 106 | { 107 | name: 'Australia', 108 | capital: 'Canberra', 109 | languages: ['English'], 110 | population: 24117360, 111 | flag: 'https://restcountries.eu/data/aus.svg', 112 | currency: 'Australian dollar' 113 | }, 114 | { 115 | name: 'Austria', 116 | capital: 'Vienna', 117 | languages: ['German'], 118 | population: 8725931, 119 | flag: 'https://restcountries.eu/data/aut.svg', 120 | currency: 'Euro' 121 | }, 122 | { 123 | name: 'Azerbaijan', 124 | capital: 'Baku', 125 | languages: ['Azerbaijani'], 126 | population: 9730500, 127 | flag: 'https://restcountries.eu/data/aze.svg', 128 | currency: 'Azerbaijani manat' 129 | }, 130 | { 131 | name: 'Bahamas', 132 | capital: 'Nassau', 133 | languages: ['English'], 134 | population: 378040, 135 | flag: 'https://restcountries.eu/data/bhs.svg', 136 | currency: 'Bahamian dollar' 137 | }, 138 | { 139 | name: 'Bahrain', 140 | capital: 'Manama', 141 | languages: ['Arabic'], 142 | population: 1404900, 143 | flag: 'https://restcountries.eu/data/bhr.svg', 144 | currency: 'Bahraini dinar' 145 | }, 146 | { 147 | name: 'Bangladesh', 148 | capital: 'Dhaka', 149 | languages: ['Bengali'], 150 | population: 161006790, 151 | flag: 'https://restcountries.eu/data/bgd.svg', 152 | currency: 'Bangladeshi taka' 153 | }, 154 | { 155 | name: 'Barbados', 156 | capital: 'Bridgetown', 157 | languages: ['English'], 158 | population: 285000, 159 | flag: 'https://restcountries.eu/data/brb.svg', 160 | currency: 'Barbadian dollar' 161 | }, 162 | { 163 | name: 'Belarus', 164 | capital: 'Minsk', 165 | languages: ['Belarusian', 'Russian'], 166 | population: 9498700, 167 | flag: 'https://restcountries.eu/data/blr.svg', 168 | currency: 'New Belarusian ruble' 169 | }, 170 | { 171 | name: 'Belgium', 172 | capital: 'Brussels', 173 | languages: ['Dutch', 'French', 'German'], 174 | population: 11319511, 175 | flag: 'https://restcountries.eu/data/bel.svg', 176 | currency: 'Euro' 177 | }, 178 | { 179 | name: 'Belize', 180 | capital: 'Belmopan', 181 | languages: ['English', 'Spanish'], 182 | population: 370300, 183 | flag: 'https://restcountries.eu/data/blz.svg', 184 | currency: 'Belize dollar' 185 | }, 186 | { 187 | name: 'Benin', 188 | capital: 'Porto-Novo', 189 | languages: ['French'], 190 | population: 10653654, 191 | flag: 'https://restcountries.eu/data/ben.svg', 192 | currency: 'West African CFA franc' 193 | }, 194 | { 195 | name: 'Bermuda', 196 | capital: 'Hamilton', 197 | languages: ['English'], 198 | population: 61954, 199 | flag: 'https://restcountries.eu/data/bmu.svg', 200 | currency: 'Bermudian dollar' 201 | }, 202 | { 203 | name: 'Bhutan', 204 | capital: 'Thimphu', 205 | languages: ['Dzongkha'], 206 | population: 775620, 207 | flag: 'https://restcountries.eu/data/btn.svg', 208 | currency: 'Bhutanese ngultrum' 209 | }, 210 | { 211 | name: 'Bolivia (Plurinational State of)', 212 | capital: 'Sucre', 213 | languages: ['Spanish', 'Aymara', 'Quechua'], 214 | population: 10985059, 215 | flag: 'https://restcountries.eu/data/bol.svg', 216 | currency: 'Bolivian boliviano' 217 | }, 218 | { 219 | name: 'Bonaire, Sint Eustatius and Saba', 220 | capital: 'Kralendijk', 221 | languages: ['Dutch'], 222 | population: 17408, 223 | flag: 'https://restcountries.eu/data/bes.svg', 224 | currency: 'United States dollar' 225 | }, 226 | { 227 | name: 'Bosnia and Herzegovina', 228 | capital: 'Sarajevo', 229 | languages: ['Bosnian', 'Croatian', 'Serbian'], 230 | population: 3531159, 231 | flag: 'https://restcountries.eu/data/bih.svg', 232 | currency: 'Bosnia and Herzegovina convertible mark' 233 | }, 234 | { 235 | name: 'Botswana', 236 | capital: 'Gaborone', 237 | languages: ['English', 'Tswana'], 238 | population: 2141206, 239 | flag: 'https://restcountries.eu/data/bwa.svg', 240 | currency: 'Botswana pula' 241 | }, 242 | { 243 | name: 'Bouvet Island', 244 | capital: '', 245 | languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], 246 | population: 0, 247 | flag: 'https://restcountries.eu/data/bvt.svg', 248 | currency: 'Norwegian krone' 249 | }, 250 | { 251 | name: 'Brazil', 252 | capital: 'Brasília', 253 | languages: ['Portuguese'], 254 | population: 206135893, 255 | flag: 'https://restcountries.eu/data/bra.svg', 256 | currency: 'Brazilian real' 257 | }, 258 | { 259 | name: 'British Indian Ocean Territory', 260 | capital: 'Diego Garcia', 261 | languages: ['English'], 262 | population: 3000, 263 | flag: 'https://restcountries.eu/data/iot.svg', 264 | currency: 'United States dollar' 265 | }, 266 | { 267 | name: 'United States Minor Outlying Islands', 268 | capital: '', 269 | languages: ['English'], 270 | population: 300, 271 | flag: 'https://restcountries.eu/data/umi.svg', 272 | currency: 'United States Dollar' 273 | }, 274 | { 275 | name: 'Virgin Islands (British)', 276 | capital: 'Road Town', 277 | languages: ['English'], 278 | population: 28514, 279 | flag: 'https://restcountries.eu/data/vgb.svg', 280 | currency: '[D]' 281 | }, 282 | { 283 | name: 'Virgin Islands (U.S.)', 284 | capital: 'Charlotte Amalie', 285 | languages: ['English'], 286 | population: 114743, 287 | flag: 'https://restcountries.eu/data/vir.svg', 288 | currency: 'United States dollar' 289 | }, 290 | { 291 | name: 'Brunei Darussalam', 292 | capital: 'Bandar Seri Begawan', 293 | languages: ['Malay'], 294 | population: 411900, 295 | flag: 'https://restcountries.eu/data/brn.svg', 296 | currency: 'Brunei dollar' 297 | }, 298 | { 299 | name: 'Bulgaria', 300 | capital: 'Sofia', 301 | languages: ['Bulgarian'], 302 | population: 7153784, 303 | flag: 'https://restcountries.eu/data/bgr.svg', 304 | currency: 'Bulgarian lev' 305 | }, 306 | { 307 | name: 'Burkina Faso', 308 | capital: 'Ouagadougou', 309 | languages: ['French', 'Fula'], 310 | population: 19034397, 311 | flag: 'https://restcountries.eu/data/bfa.svg', 312 | currency: 'West African CFA franc' 313 | }, 314 | { 315 | name: 'Burundi', 316 | capital: 'Bujumbura', 317 | languages: ['French', 'Kirundi'], 318 | population: 10114505, 319 | flag: 'https://restcountries.eu/data/bdi.svg', 320 | currency: 'Burundian franc' 321 | }, 322 | { 323 | name: 'Cambodia', 324 | capital: 'Phnom Penh', 325 | languages: ['Khmer'], 326 | population: 15626444, 327 | flag: 'https://restcountries.eu/data/khm.svg', 328 | currency: 'Cambodian riel' 329 | }, 330 | { 331 | name: 'Cameroon', 332 | capital: 'Yaoundé', 333 | languages: ['English', 'French'], 334 | population: 22709892, 335 | flag: 'https://restcountries.eu/data/cmr.svg', 336 | currency: 'Central African CFA franc' 337 | }, 338 | { 339 | name: 'Canada', 340 | capital: 'Ottawa', 341 | languages: ['English', 'French'], 342 | population: 36155487, 343 | flag: 'https://restcountries.eu/data/can.svg', 344 | currency: 'Canadian dollar' 345 | }, 346 | { 347 | name: 'Cabo Verde', 348 | capital: 'Praia', 349 | languages: ['Portuguese'], 350 | population: 531239, 351 | flag: 'https://restcountries.eu/data/cpv.svg', 352 | currency: 'Cape Verdean escudo' 353 | }, 354 | { 355 | name: 'Cayman Islands', 356 | capital: 'George Town', 357 | languages: ['English'], 358 | population: 58238, 359 | flag: 'https://restcountries.eu/data/cym.svg', 360 | currency: 'Cayman Islands dollar' 361 | }, 362 | { 363 | name: 'Central African Republic', 364 | capital: 'Bangui', 365 | languages: ['French', 'Sango'], 366 | population: 4998000, 367 | flag: 'https://restcountries.eu/data/caf.svg', 368 | currency: 'Central African CFA franc' 369 | }, 370 | { 371 | name: 'Chad', 372 | capital: "N'Djamena", 373 | languages: ['French', 'Arabic'], 374 | population: 14497000, 375 | flag: 'https://restcountries.eu/data/tcd.svg', 376 | currency: 'Central African CFA franc' 377 | }, 378 | { 379 | name: 'Chile', 380 | capital: 'Santiago', 381 | languages: ['Spanish'], 382 | population: 18191900, 383 | flag: 'https://restcountries.eu/data/chl.svg', 384 | currency: 'Chilean peso' 385 | }, 386 | { 387 | name: 'China', 388 | capital: 'Beijing', 389 | languages: ['Chinese'], 390 | population: 1377422166, 391 | flag: 'https://restcountries.eu/data/chn.svg', 392 | currency: 'Chinese yuan' 393 | }, 394 | { 395 | name: 'Christmas Island', 396 | capital: 'Flying Fish Cove', 397 | languages: ['English'], 398 | population: 2072, 399 | flag: 'https://restcountries.eu/data/cxr.svg', 400 | currency: 'Australian dollar' 401 | }, 402 | { 403 | name: 'Cocos (Keeling) Islands', 404 | capital: 'West Island', 405 | languages: ['English'], 406 | population: 550, 407 | flag: 'https://restcountries.eu/data/cck.svg', 408 | currency: 'Australian dollar' 409 | }, 410 | { 411 | name: 'Colombia', 412 | capital: 'Bogotá', 413 | languages: ['Spanish'], 414 | population: 48759958, 415 | flag: 'https://restcountries.eu/data/col.svg', 416 | currency: 'Colombian peso' 417 | }, 418 | { 419 | name: 'Comoros', 420 | capital: 'Moroni', 421 | languages: ['Arabic', 'French'], 422 | population: 806153, 423 | flag: 'https://restcountries.eu/data/com.svg', 424 | currency: 'Comorian franc' 425 | }, 426 | { 427 | name: 'Congo', 428 | capital: 'Brazzaville', 429 | languages: ['French', 'Lingala'], 430 | population: 4741000, 431 | flag: 'https://restcountries.eu/data/cog.svg', 432 | currency: 'Central African CFA franc' 433 | }, 434 | { 435 | name: 'Congo (Democratic Republic of the)', 436 | capital: 'Kinshasa', 437 | languages: ['French', 'Lingala', 'Kongo', 'Swahili', 'Luba-Katanga'], 438 | population: 85026000, 439 | flag: 'https://restcountries.eu/data/cod.svg', 440 | currency: 'Congolese franc' 441 | }, 442 | { 443 | name: 'Cook Islands', 444 | capital: 'Avarua', 445 | languages: ['English'], 446 | population: 18100, 447 | flag: 'https://restcountries.eu/data/cok.svg', 448 | currency: 'New Zealand dollar' 449 | }, 450 | { 451 | name: 'Costa Rica', 452 | capital: 'San José', 453 | languages: ['Spanish'], 454 | population: 4890379, 455 | flag: 'https://restcountries.eu/data/cri.svg', 456 | currency: 'Costa Rican colón' 457 | }, 458 | { 459 | name: 'Croatia', 460 | capital: 'Zagreb', 461 | languages: ['Croatian'], 462 | population: 4190669, 463 | flag: 'https://restcountries.eu/data/hrv.svg', 464 | currency: 'Croatian kuna' 465 | }, 466 | { 467 | name: 'Cuba', 468 | capital: 'Havana', 469 | languages: ['Spanish'], 470 | population: 11239004, 471 | flag: 'https://restcountries.eu/data/cub.svg', 472 | currency: 'Cuban convertible peso' 473 | }, 474 | { 475 | name: 'Curaçao', 476 | capital: 'Willemstad', 477 | languages: ['Dutch', '(Eastern) Punjabi', 'English'], 478 | population: 154843, 479 | flag: 'https://restcountries.eu/data/cuw.svg', 480 | currency: 'Netherlands Antillean guilder' 481 | }, 482 | { 483 | name: 'Cyprus', 484 | capital: 'Nicosia', 485 | languages: ['Greek (modern)', 'Turkish', 'Armenian'], 486 | population: 847000, 487 | flag: 'https://restcountries.eu/data/cyp.svg', 488 | currency: 'Euro' 489 | }, 490 | { 491 | name: 'Czech Republic', 492 | capital: 'Prague', 493 | languages: ['Czech', 'Slovak'], 494 | population: 10558524, 495 | flag: 'https://restcountries.eu/data/cze.svg', 496 | currency: 'Czech koruna' 497 | }, 498 | { 499 | name: 'Denmark', 500 | capital: 'Copenhagen', 501 | languages: ['Danish'], 502 | population: 5717014, 503 | flag: 'https://restcountries.eu/data/dnk.svg', 504 | currency: 'Danish krone' 505 | }, 506 | { 507 | name: 'Djibouti', 508 | capital: 'Djibouti', 509 | languages: ['French', 'Arabic'], 510 | population: 900000, 511 | flag: 'https://restcountries.eu/data/dji.svg', 512 | currency: 'Djiboutian franc' 513 | }, 514 | { 515 | name: 'Dominica', 516 | capital: 'Roseau', 517 | languages: ['English'], 518 | population: 71293, 519 | flag: 'https://restcountries.eu/data/dma.svg', 520 | currency: 'East Caribbean dollar' 521 | }, 522 | { 523 | name: 'Dominican Republic', 524 | capital: 'Santo Domingo', 525 | languages: ['Spanish'], 526 | population: 10075045, 527 | flag: 'https://restcountries.eu/data/dom.svg', 528 | currency: 'Dominican peso' 529 | }, 530 | { 531 | name: 'Ecuador', 532 | capital: 'Quito', 533 | languages: ['Spanish'], 534 | population: 16545799, 535 | flag: 'https://restcountries.eu/data/ecu.svg', 536 | currency: 'United States dollar' 537 | }, 538 | { 539 | name: 'Egypt', 540 | capital: 'Cairo', 541 | languages: ['Arabic'], 542 | population: 91290000, 543 | flag: 'https://restcountries.eu/data/egy.svg', 544 | currency: 'Egyptian pound' 545 | }, 546 | { 547 | name: 'El Salvador', 548 | capital: 'San Salvador', 549 | languages: ['Spanish'], 550 | population: 6520675, 551 | flag: 'https://restcountries.eu/data/slv.svg', 552 | currency: 'United States dollar' 553 | }, 554 | { 555 | name: 'Equatorial Guinea', 556 | capital: 'Malabo', 557 | languages: ['Spanish', 'French'], 558 | population: 1222442, 559 | flag: 'https://restcountries.eu/data/gnq.svg', 560 | currency: 'Central African CFA franc' 561 | }, 562 | { 563 | name: 'Eritrea', 564 | capital: 'Asmara', 565 | languages: ['Tigrinya', 'Arabic', 'English'], 566 | population: 5352000, 567 | flag: 'https://restcountries.eu/data/eri.svg', 568 | currency: 'Eritrean nakfa' 569 | }, 570 | { 571 | name: 'Estonia', 572 | capital: 'Tallinn', 573 | languages: ['Estonian'], 574 | population: 1315944, 575 | flag: 'https://restcountries.eu/data/est.svg', 576 | currency: 'Euro' 577 | }, 578 | { 579 | name: 'Ethiopia', 580 | capital: 'Addis Ababa', 581 | languages: ['Amharic'], 582 | population: 92206005, 583 | flag: 'https://restcountries.eu/data/eth.svg', 584 | currency: 'Ethiopian birr' 585 | }, 586 | { 587 | name: 'Falkland Islands (Malvinas)', 588 | capital: 'Stanley', 589 | languages: ['English'], 590 | population: 2563, 591 | flag: 'https://restcountries.eu/data/flk.svg', 592 | currency: 'Falkland Islands pound' 593 | }, 594 | { 595 | name: 'Faroe Islands', 596 | capital: 'Tórshavn', 597 | languages: ['Faroese'], 598 | population: 49376, 599 | flag: 'https://restcountries.eu/data/fro.svg', 600 | currency: 'Danish krone' 601 | }, 602 | { 603 | name: 'Fiji', 604 | capital: 'Suva', 605 | languages: ['English', 'Fijian', 'Hindi', 'Urdu'], 606 | population: 867000, 607 | flag: 'https://restcountries.eu/data/fji.svg', 608 | currency: 'Fijian dollar' 609 | }, 610 | { 611 | name: 'Finland', 612 | capital: 'Helsinki', 613 | languages: ['Finnish', 'Swedish'], 614 | population: 5491817, 615 | flag: 'https://restcountries.eu/data/fin.svg', 616 | currency: 'Euro' 617 | }, 618 | { 619 | name: 'France', 620 | capital: 'Paris', 621 | languages: ['French'], 622 | population: 66710000, 623 | flag: 'https://restcountries.eu/data/fra.svg', 624 | currency: 'Euro' 625 | }, 626 | { 627 | name: 'French Guiana', 628 | capital: 'Cayenne', 629 | languages: ['French'], 630 | population: 254541, 631 | flag: 'https://restcountries.eu/data/guf.svg', 632 | currency: 'Euro' 633 | }, 634 | { 635 | name: 'French Polynesia', 636 | capital: 'Papeetē', 637 | languages: ['French'], 638 | population: 271800, 639 | flag: 'https://restcountries.eu/data/pyf.svg', 640 | currency: 'CFP franc' 641 | }, 642 | { 643 | name: 'French Southern Territories', 644 | capital: 'Port-aux-Français', 645 | languages: ['French'], 646 | population: 140, 647 | flag: 'https://restcountries.eu/data/atf.svg', 648 | currency: 'Euro' 649 | }, 650 | { 651 | name: 'Gabon', 652 | capital: 'Libreville', 653 | languages: ['French'], 654 | population: 1802278, 655 | flag: 'https://restcountries.eu/data/gab.svg', 656 | currency: 'Central African CFA franc' 657 | }, 658 | { 659 | name: 'Gambia', 660 | capital: 'Banjul', 661 | languages: ['English'], 662 | population: 1882450, 663 | flag: 'https://restcountries.eu/data/gmb.svg', 664 | currency: 'Gambian dalasi' 665 | }, 666 | { 667 | name: 'Georgia', 668 | capital: 'Tbilisi', 669 | languages: ['Georgian'], 670 | population: 3720400, 671 | flag: 'https://restcountries.eu/data/geo.svg', 672 | currency: 'Georgian Lari' 673 | }, 674 | { 675 | name: 'Germany', 676 | capital: 'Berlin', 677 | languages: ['German'], 678 | population: 81770900, 679 | flag: 'https://restcountries.eu/data/deu.svg', 680 | currency: 'Euro' 681 | }, 682 | { 683 | name: 'Ghana', 684 | capital: 'Accra', 685 | languages: ['English'], 686 | population: 27670174, 687 | flag: 'https://restcountries.eu/data/gha.svg', 688 | currency: 'Ghanaian cedi' 689 | }, 690 | { 691 | name: 'Gibraltar', 692 | capital: 'Gibraltar', 693 | languages: ['English'], 694 | population: 33140, 695 | flag: 'https://restcountries.eu/data/gib.svg', 696 | currency: 'Gibraltar pound' 697 | }, 698 | { 699 | name: 'Greece', 700 | capital: 'Athens', 701 | languages: ['Greek (modern)'], 702 | population: 10858018, 703 | flag: 'https://restcountries.eu/data/grc.svg', 704 | currency: 'Euro' 705 | }, 706 | { 707 | name: 'Greenland', 708 | capital: 'Nuuk', 709 | languages: ['Kalaallisut'], 710 | population: 55847, 711 | flag: 'https://restcountries.eu/data/grl.svg', 712 | currency: 'Danish krone' 713 | }, 714 | { 715 | name: 'Grenada', 716 | capital: "St. George's", 717 | languages: ['English'], 718 | population: 103328, 719 | flag: 'https://restcountries.eu/data/grd.svg', 720 | currency: 'East Caribbean dollar' 721 | }, 722 | { 723 | name: 'Guadeloupe', 724 | capital: 'Basse-Terre', 725 | languages: ['French'], 726 | population: 400132, 727 | flag: 'https://restcountries.eu/data/glp.svg', 728 | currency: 'Euro' 729 | }, 730 | { 731 | name: 'Guam', 732 | capital: 'Hagåtña', 733 | languages: ['English', 'Chamorro', 'Spanish'], 734 | population: 184200, 735 | flag: 'https://restcountries.eu/data/gum.svg', 736 | currency: 'United States dollar' 737 | }, 738 | { 739 | name: 'Guatemala', 740 | capital: 'Guatemala City', 741 | languages: ['Spanish'], 742 | population: 16176133, 743 | flag: 'https://restcountries.eu/data/gtm.svg', 744 | currency: 'Guatemalan quetzal' 745 | }, 746 | { 747 | name: 'Guernsey', 748 | capital: 'St. Peter Port', 749 | languages: ['English', 'French'], 750 | population: 62999, 751 | flag: 'https://restcountries.eu/data/ggy.svg', 752 | currency: 'British pound' 753 | }, 754 | { 755 | name: 'Guinea', 756 | capital: 'Conakry', 757 | languages: ['French', 'Fula'], 758 | population: 12947000, 759 | flag: 'https://restcountries.eu/data/gin.svg', 760 | currency: 'Guinean franc' 761 | }, 762 | { 763 | name: 'Guinea-Bissau', 764 | capital: 'Bissau', 765 | languages: ['Portuguese'], 766 | population: 1547777, 767 | flag: 'https://restcountries.eu/data/gnb.svg', 768 | currency: 'West African CFA franc' 769 | }, 770 | { 771 | name: 'Guyana', 772 | capital: 'Georgetown', 773 | languages: ['English'], 774 | population: 746900, 775 | flag: 'https://restcountries.eu/data/guy.svg', 776 | currency: 'Guyanese dollar' 777 | }, 778 | { 779 | name: 'Haiti', 780 | capital: 'Port-au-Prince', 781 | languages: ['French', 'Haitian'], 782 | population: 11078033, 783 | flag: 'https://restcountries.eu/data/hti.svg', 784 | currency: 'Haitian gourde' 785 | }, 786 | { 787 | name: 'Heard Island and McDonald Islands', 788 | capital: '', 789 | languages: ['English'], 790 | population: 0, 791 | flag: 'https://restcountries.eu/data/hmd.svg', 792 | currency: 'Australian dollar' 793 | }, 794 | { 795 | name: 'Holy See', 796 | capital: 'Rome', 797 | languages: ['Latin', 'Italian', 'French', 'German'], 798 | population: 451, 799 | flag: 'https://restcountries.eu/data/vat.svg', 800 | currency: 'Euro' 801 | }, 802 | { 803 | name: 'Honduras', 804 | capital: 'Tegucigalpa', 805 | languages: ['Spanish'], 806 | population: 8576532, 807 | flag: 'https://restcountries.eu/data/hnd.svg', 808 | currency: 'Honduran lempira' 809 | }, 810 | { 811 | name: 'Hong Kong', 812 | capital: 'City of Victoria', 813 | languages: ['English', 'Chinese'], 814 | population: 7324300, 815 | flag: 'https://restcountries.eu/data/hkg.svg', 816 | currency: 'Hong Kong dollar' 817 | }, 818 | { 819 | name: 'Hungary', 820 | capital: 'Budapest', 821 | languages: ['Hungarian'], 822 | population: 9823000, 823 | flag: 'https://restcountries.eu/data/hun.svg', 824 | currency: 'Hungarian forint' 825 | }, 826 | { 827 | name: 'Iceland', 828 | capital: 'Reykjavík', 829 | languages: ['Icelandic'], 830 | population: 334300, 831 | flag: 'https://restcountries.eu/data/isl.svg', 832 | currency: 'Icelandic króna' 833 | }, 834 | { 835 | name: 'India', 836 | capital: 'New Delhi', 837 | languages: ['Hindi', 'English'], 838 | population: 1295210000, 839 | flag: 'https://restcountries.eu/data/ind.svg', 840 | currency: 'Indian rupee' 841 | }, 842 | { 843 | name: 'Indonesia', 844 | capital: 'Jakarta', 845 | languages: ['Indonesian'], 846 | population: 258705000, 847 | flag: 'https://restcountries.eu/data/idn.svg', 848 | currency: 'Indonesian rupiah' 849 | }, 850 | { 851 | name: "Côte d'Ivoire", 852 | capital: 'Yamoussoukro', 853 | languages: ['French'], 854 | population: 22671331, 855 | flag: 'https://restcountries.eu/data/civ.svg', 856 | currency: 'West African CFA franc' 857 | }, 858 | { 859 | name: 'Iran (Islamic Republic of)', 860 | capital: 'Tehran', 861 | languages: ['Persian (Farsi)'], 862 | population: 79369900, 863 | flag: 'https://restcountries.eu/data/irn.svg', 864 | currency: 'Iranian rial' 865 | }, 866 | { 867 | name: 'Iraq', 868 | capital: 'Baghdad', 869 | languages: ['Arabic', 'Kurdish'], 870 | population: 37883543, 871 | flag: 'https://restcountries.eu/data/irq.svg', 872 | currency: 'Iraqi dinar' 873 | }, 874 | { 875 | name: 'Ireland', 876 | capital: 'Dublin', 877 | languages: ['Irish', 'English'], 878 | population: 6378000, 879 | flag: 'https://restcountries.eu/data/irl.svg', 880 | currency: 'Euro' 881 | }, 882 | { 883 | name: 'Isle of Man', 884 | capital: 'Douglas', 885 | languages: ['English', 'Manx'], 886 | population: 84497, 887 | flag: 'https://restcountries.eu/data/imn.svg', 888 | currency: 'British pound' 889 | }, 890 | { 891 | name: 'Israel', 892 | capital: 'Jerusalem', 893 | languages: ['Hebrew (modern)', 'Arabic'], 894 | population: 8527400, 895 | flag: 'https://restcountries.eu/data/isr.svg', 896 | currency: 'Israeli new shekel' 897 | }, 898 | { 899 | name: 'Italy', 900 | capital: 'Rome', 901 | languages: ['Italian'], 902 | population: 60665551, 903 | flag: 'https://restcountries.eu/data/ita.svg', 904 | currency: 'Euro' 905 | }, 906 | { 907 | name: 'Jamaica', 908 | capital: 'Kingston', 909 | languages: ['English'], 910 | population: 2723246, 911 | flag: 'https://restcountries.eu/data/jam.svg', 912 | currency: 'Jamaican dollar' 913 | }, 914 | { 915 | name: 'Japan', 916 | capital: 'Tokyo', 917 | languages: ['Japanese'], 918 | population: 126960000, 919 | flag: 'https://restcountries.eu/data/jpn.svg', 920 | currency: 'Japanese yen' 921 | }, 922 | { 923 | name: 'Jersey', 924 | capital: 'Saint Helier', 925 | languages: ['English', 'French'], 926 | population: 100800, 927 | flag: 'https://restcountries.eu/data/jey.svg', 928 | currency: 'British pound' 929 | }, 930 | { 931 | name: 'Jordan', 932 | capital: 'Amman', 933 | languages: ['Arabic'], 934 | population: 9531712, 935 | flag: 'https://restcountries.eu/data/jor.svg', 936 | currency: 'Jordanian dinar' 937 | }, 938 | { 939 | name: 'Kazakhstan', 940 | capital: 'Astana', 941 | languages: ['Kazakh', 'Russian'], 942 | population: 17753200, 943 | flag: 'https://restcountries.eu/data/kaz.svg', 944 | currency: 'Kazakhstani tenge' 945 | }, 946 | { 947 | name: 'Kenya', 948 | capital: 'Nairobi', 949 | languages: ['English', 'Swahili'], 950 | population: 47251000, 951 | flag: 'https://restcountries.eu/data/ken.svg', 952 | currency: 'Kenyan shilling' 953 | }, 954 | { 955 | name: 'Kiribati', 956 | capital: 'South Tarawa', 957 | languages: ['English'], 958 | population: 113400, 959 | flag: 'https://restcountries.eu/data/kir.svg', 960 | currency: 'Australian dollar' 961 | }, 962 | { 963 | name: 'Kuwait', 964 | capital: 'Kuwait City', 965 | languages: ['Arabic'], 966 | population: 4183658, 967 | flag: 'https://restcountries.eu/data/kwt.svg', 968 | currency: 'Kuwaiti dinar' 969 | }, 970 | { 971 | name: 'Kyrgyzstan', 972 | capital: 'Bishkek', 973 | languages: ['Kyrgyz', 'Russian'], 974 | population: 6047800, 975 | flag: 'https://restcountries.eu/data/kgz.svg', 976 | currency: 'Kyrgyzstani som' 977 | }, 978 | { 979 | name: "Lao People's Democratic Republic", 980 | capital: 'Vientiane', 981 | languages: ['Lao'], 982 | population: 6492400, 983 | flag: 'https://restcountries.eu/data/lao.svg', 984 | currency: 'Lao kip' 985 | }, 986 | { 987 | name: 'Latvia', 988 | capital: 'Riga', 989 | languages: ['Latvian'], 990 | population: 1961600, 991 | flag: 'https://restcountries.eu/data/lva.svg', 992 | currency: 'Euro' 993 | }, 994 | { 995 | name: 'Lebanon', 996 | capital: 'Beirut', 997 | languages: ['Arabic', 'French'], 998 | population: 5988000, 999 | flag: 'https://restcountries.eu/data/lbn.svg', 1000 | currency: 'Lebanese pound' 1001 | }, 1002 | { 1003 | name: 'Lesotho', 1004 | capital: 'Maseru', 1005 | languages: ['English', 'Southern Sotho'], 1006 | population: 1894194, 1007 | flag: 'https://restcountries.eu/data/lso.svg', 1008 | currency: 'Lesotho loti' 1009 | }, 1010 | { 1011 | name: 'Liberia', 1012 | capital: 'Monrovia', 1013 | languages: ['English'], 1014 | population: 4615000, 1015 | flag: 'https://restcountries.eu/data/lbr.svg', 1016 | currency: 'Liberian dollar' 1017 | }, 1018 | { 1019 | name: 'Libya', 1020 | capital: 'Tripoli', 1021 | languages: ['Arabic'], 1022 | population: 6385000, 1023 | flag: 'https://restcountries.eu/data/lby.svg', 1024 | currency: 'Libyan dinar' 1025 | }, 1026 | { 1027 | name: 'Liechtenstein', 1028 | capital: 'Vaduz', 1029 | languages: ['German'], 1030 | population: 37623, 1031 | flag: 'https://restcountries.eu/data/lie.svg', 1032 | currency: 'Swiss franc' 1033 | }, 1034 | { 1035 | name: 'Lithuania', 1036 | capital: 'Vilnius', 1037 | languages: ['Lithuanian'], 1038 | population: 2872294, 1039 | flag: 'https://restcountries.eu/data/ltu.svg', 1040 | currency: 'Euro' 1041 | }, 1042 | { 1043 | name: 'Luxembourg', 1044 | capital: 'Luxembourg', 1045 | languages: ['French', 'German', 'Luxembourgish'], 1046 | population: 576200, 1047 | flag: 'https://restcountries.eu/data/lux.svg', 1048 | currency: 'Euro' 1049 | }, 1050 | { 1051 | name: 'Macao', 1052 | capital: '', 1053 | languages: ['Chinese', 'Portuguese'], 1054 | population: 649100, 1055 | flag: 'https://restcountries.eu/data/mac.svg', 1056 | currency: 'Macanese pataca' 1057 | }, 1058 | { 1059 | name: 'Macedonia (the former Yugoslav Republic of)', 1060 | capital: 'Skopje', 1061 | languages: ['Macedonian'], 1062 | population: 2058539, 1063 | flag: 'https://restcountries.eu/data/mkd.svg', 1064 | currency: 'Macedonian denar' 1065 | }, 1066 | { 1067 | name: 'Madagascar', 1068 | capital: 'Antananarivo', 1069 | languages: ['French', 'Malagasy'], 1070 | population: 22434363, 1071 | flag: 'https://restcountries.eu/data/mdg.svg', 1072 | currency: 'Malagasy ariary' 1073 | }, 1074 | { 1075 | name: 'Malawi', 1076 | capital: 'Lilongwe', 1077 | languages: ['English', 'Chichewa'], 1078 | population: 16832910, 1079 | flag: 'https://restcountries.eu/data/mwi.svg', 1080 | currency: 'Malawian kwacha' 1081 | }, 1082 | { 1083 | name: 'Malaysia', 1084 | capital: 'Kuala Lumpur', 1085 | languages: ['Malaysian'], 1086 | population: 31405416, 1087 | flag: 'https://restcountries.eu/data/mys.svg', 1088 | currency: 'Malaysian ringgit' 1089 | }, 1090 | { 1091 | name: 'Maldives', 1092 | capital: 'Malé', 1093 | languages: ['Divehi'], 1094 | population: 344023, 1095 | flag: 'https://restcountries.eu/data/mdv.svg', 1096 | currency: 'Maldivian rufiyaa' 1097 | }, 1098 | { 1099 | name: 'Mali', 1100 | capital: 'Bamako', 1101 | languages: ['French'], 1102 | population: 18135000, 1103 | flag: 'https://restcountries.eu/data/mli.svg', 1104 | currency: 'West African CFA franc' 1105 | }, 1106 | { 1107 | name: 'Malta', 1108 | capital: 'Valletta', 1109 | languages: ['Maltese', 'English'], 1110 | population: 425384, 1111 | flag: 'https://restcountries.eu/data/mlt.svg', 1112 | currency: 'Euro' 1113 | }, 1114 | { 1115 | name: 'Marshall Islands', 1116 | capital: 'Majuro', 1117 | languages: ['English', 'Marshallese'], 1118 | population: 54880, 1119 | flag: 'https://restcountries.eu/data/mhl.svg', 1120 | currency: 'United States dollar' 1121 | }, 1122 | { 1123 | name: 'Martinique', 1124 | capital: 'Fort-de-France', 1125 | languages: ['French'], 1126 | population: 378243, 1127 | flag: 'https://restcountries.eu/data/mtq.svg', 1128 | currency: 'Euro' 1129 | }, 1130 | { 1131 | name: 'Mauritania', 1132 | capital: 'Nouakchott', 1133 | languages: ['Arabic'], 1134 | population: 3718678, 1135 | flag: 'https://restcountries.eu/data/mrt.svg', 1136 | currency: 'Mauritanian ouguiya' 1137 | }, 1138 | { 1139 | name: 'Mauritius', 1140 | capital: 'Port Louis', 1141 | languages: ['English'], 1142 | population: 1262879, 1143 | flag: 'https://restcountries.eu/data/mus.svg', 1144 | currency: 'Mauritian rupee' 1145 | }, 1146 | { 1147 | name: 'Mayotte', 1148 | capital: 'Mamoudzou', 1149 | languages: ['French'], 1150 | population: 226915, 1151 | flag: 'https://restcountries.eu/data/myt.svg', 1152 | currency: 'Euro' 1153 | }, 1154 | { 1155 | name: 'Mexico', 1156 | capital: 'Mexico City', 1157 | languages: ['Spanish'], 1158 | population: 122273473, 1159 | flag: 'https://restcountries.eu/data/mex.svg', 1160 | currency: 'Mexican peso' 1161 | }, 1162 | { 1163 | name: 'Micronesia (Federated States of)', 1164 | capital: 'Palikir', 1165 | languages: ['English'], 1166 | population: 102800, 1167 | flag: 'https://restcountries.eu/data/fsm.svg', 1168 | currency: '[D]' 1169 | }, 1170 | { 1171 | name: 'Moldova (Republic of)', 1172 | capital: 'Chișinău', 1173 | languages: ['Romanian'], 1174 | population: 3553100, 1175 | flag: 'https://restcountries.eu/data/mda.svg', 1176 | currency: 'Moldovan leu' 1177 | }, 1178 | { 1179 | name: 'Monaco', 1180 | capital: 'Monaco', 1181 | languages: ['French'], 1182 | population: 38400, 1183 | flag: 'https://restcountries.eu/data/mco.svg', 1184 | currency: 'Euro' 1185 | }, 1186 | { 1187 | name: 'Mongolia', 1188 | capital: 'Ulan Bator', 1189 | languages: ['Mongolian'], 1190 | population: 3093100, 1191 | flag: 'https://restcountries.eu/data/mng.svg', 1192 | currency: 'Mongolian tögrög' 1193 | }, 1194 | { 1195 | name: 'Montenegro', 1196 | capital: 'Podgorica', 1197 | languages: ['Serbian', 'Bosnian', 'Albanian', 'Croatian'], 1198 | population: 621810, 1199 | flag: 'https://restcountries.eu/data/mne.svg', 1200 | currency: 'Euro' 1201 | }, 1202 | { 1203 | name: 'Montserrat', 1204 | capital: 'Plymouth', 1205 | languages: ['English'], 1206 | population: 4922, 1207 | flag: 'https://restcountries.eu/data/msr.svg', 1208 | currency: 'East Caribbean dollar' 1209 | }, 1210 | { 1211 | name: 'Morocco', 1212 | capital: 'Rabat', 1213 | languages: ['Arabic'], 1214 | population: 33337529, 1215 | flag: 'https://restcountries.eu/data/mar.svg', 1216 | currency: 'Moroccan dirham' 1217 | }, 1218 | { 1219 | name: 'Mozambique', 1220 | capital: 'Maputo', 1221 | languages: ['Portuguese'], 1222 | population: 26423700, 1223 | flag: 'https://restcountries.eu/data/moz.svg', 1224 | currency: 'Mozambican metical' 1225 | }, 1226 | { 1227 | name: 'Myanmar', 1228 | capital: 'Naypyidaw', 1229 | languages: ['Burmese'], 1230 | population: 51419420, 1231 | flag: 'https://restcountries.eu/data/mmr.svg', 1232 | currency: 'Burmese kyat' 1233 | }, 1234 | { 1235 | name: 'Namibia', 1236 | capital: 'Windhoek', 1237 | languages: ['English', 'Afrikaans'], 1238 | population: 2324388, 1239 | flag: 'https://restcountries.eu/data/nam.svg', 1240 | currency: 'Namibian dollar' 1241 | }, 1242 | { 1243 | name: 'Nauru', 1244 | capital: 'Yaren', 1245 | languages: ['English', 'Nauruan'], 1246 | population: 10084, 1247 | flag: 'https://restcountries.eu/data/nru.svg', 1248 | currency: 'Australian dollar' 1249 | }, 1250 | { 1251 | name: 'Nepal', 1252 | capital: 'Kathmandu', 1253 | languages: ['Nepali'], 1254 | population: 28431500, 1255 | flag: 'https://restcountries.eu/data/npl.svg', 1256 | currency: 'Nepalese rupee' 1257 | }, 1258 | { 1259 | name: 'Netherlands', 1260 | capital: 'Amsterdam', 1261 | languages: ['Dutch'], 1262 | population: 17019800, 1263 | flag: 'https://restcountries.eu/data/nld.svg', 1264 | currency: 'Euro' 1265 | }, 1266 | { 1267 | name: 'New Caledonia', 1268 | capital: 'Nouméa', 1269 | languages: ['French'], 1270 | population: 268767, 1271 | flag: 'https://restcountries.eu/data/ncl.svg', 1272 | currency: 'CFP franc' 1273 | }, 1274 | { 1275 | name: 'New Zealand', 1276 | capital: 'Wellington', 1277 | languages: ['English', 'Māori'], 1278 | population: 4697854, 1279 | flag: 'https://restcountries.eu/data/nzl.svg', 1280 | currency: 'New Zealand dollar' 1281 | }, 1282 | { 1283 | name: 'Nicaragua', 1284 | capital: 'Managua', 1285 | languages: ['Spanish'], 1286 | population: 6262703, 1287 | flag: 'https://restcountries.eu/data/nic.svg', 1288 | currency: 'Nicaraguan córdoba' 1289 | }, 1290 | { 1291 | name: 'Niger', 1292 | capital: 'Niamey', 1293 | languages: ['French'], 1294 | population: 20715000, 1295 | flag: 'https://restcountries.eu/data/ner.svg', 1296 | currency: 'West African CFA franc' 1297 | }, 1298 | { 1299 | name: 'Nigeria', 1300 | capital: 'Abuja', 1301 | languages: ['English'], 1302 | population: 186988000, 1303 | flag: 'https://restcountries.eu/data/nga.svg', 1304 | currency: 'Nigerian naira' 1305 | }, 1306 | { 1307 | name: 'Niue', 1308 | capital: 'Alofi', 1309 | languages: ['English'], 1310 | population: 1470, 1311 | flag: 'https://restcountries.eu/data/niu.svg', 1312 | currency: 'New Zealand dollar' 1313 | }, 1314 | { 1315 | name: 'Norfolk Island', 1316 | capital: 'Kingston', 1317 | languages: ['English'], 1318 | population: 2302, 1319 | flag: 'https://restcountries.eu/data/nfk.svg', 1320 | currency: 'Australian dollar' 1321 | }, 1322 | { 1323 | name: "Korea (Democratic People's Republic of)", 1324 | capital: 'Pyongyang', 1325 | languages: ['Korean'], 1326 | population: 25281000, 1327 | flag: 'https://restcountries.eu/data/prk.svg', 1328 | currency: 'North Korean won' 1329 | }, 1330 | { 1331 | name: 'Northern Mariana Islands', 1332 | capital: 'Saipan', 1333 | languages: ['English', 'Chamorro'], 1334 | population: 56940, 1335 | flag: 'https://restcountries.eu/data/mnp.svg', 1336 | currency: 'United States dollar' 1337 | }, 1338 | { 1339 | name: 'Norway', 1340 | capital: 'Oslo', 1341 | languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], 1342 | population: 5223256, 1343 | flag: 'https://restcountries.eu/data/nor.svg', 1344 | currency: 'Norwegian krone' 1345 | }, 1346 | { 1347 | name: 'Oman', 1348 | capital: 'Muscat', 1349 | languages: ['Arabic'], 1350 | population: 4420133, 1351 | flag: 'https://restcountries.eu/data/omn.svg', 1352 | currency: 'Omani rial' 1353 | }, 1354 | { 1355 | name: 'Pakistan', 1356 | capital: 'Islamabad', 1357 | languages: ['English', 'Urdu'], 1358 | population: 194125062, 1359 | flag: 'https://restcountries.eu/data/pak.svg', 1360 | currency: 'Pakistani rupee' 1361 | }, 1362 | { 1363 | name: 'Palau', 1364 | capital: 'Ngerulmud', 1365 | languages: ['English'], 1366 | population: 17950, 1367 | flag: 'https://restcountries.eu/data/plw.svg', 1368 | currency: '[E]' 1369 | }, 1370 | { 1371 | name: 'Palestine, State of', 1372 | capital: 'Ramallah', 1373 | languages: ['Arabic'], 1374 | population: 4682467, 1375 | flag: 'https://restcountries.eu/data/pse.svg', 1376 | currency: 'Israeli new sheqel' 1377 | }, 1378 | { 1379 | name: 'Panama', 1380 | capital: 'Panama City', 1381 | languages: ['Spanish'], 1382 | population: 3814672, 1383 | flag: 'https://restcountries.eu/data/pan.svg', 1384 | currency: 'Panamanian balboa' 1385 | }, 1386 | { 1387 | name: 'Papua New Guinea', 1388 | capital: 'Port Moresby', 1389 | languages: ['English'], 1390 | population: 8083700, 1391 | flag: 'https://restcountries.eu/data/png.svg', 1392 | currency: 'Papua New Guinean kina' 1393 | }, 1394 | { 1395 | name: 'Paraguay', 1396 | capital: 'Asunción', 1397 | languages: ['Spanish', 'Guaraní'], 1398 | population: 6854536, 1399 | flag: 'https://restcountries.eu/data/pry.svg', 1400 | currency: 'Paraguayan guaraní' 1401 | }, 1402 | { 1403 | name: 'Peru', 1404 | capital: 'Lima', 1405 | languages: ['Spanish'], 1406 | population: 31488700, 1407 | flag: 'https://restcountries.eu/data/per.svg', 1408 | currency: 'Peruvian sol' 1409 | }, 1410 | { 1411 | name: 'Philippines', 1412 | capital: 'Manila', 1413 | languages: ['English'], 1414 | population: 103279800, 1415 | flag: 'https://restcountries.eu/data/phl.svg', 1416 | currency: 'Philippine peso' 1417 | }, 1418 | { 1419 | name: 'Pitcairn', 1420 | capital: 'Adamstown', 1421 | languages: ['English'], 1422 | population: 56, 1423 | flag: 'https://restcountries.eu/data/pcn.svg', 1424 | currency: 'New Zealand dollar' 1425 | }, 1426 | { 1427 | name: 'Poland', 1428 | capital: 'Warsaw', 1429 | languages: ['Polish'], 1430 | population: 38437239, 1431 | flag: 'https://restcountries.eu/data/pol.svg', 1432 | currency: 'Polish złoty' 1433 | }, 1434 | { 1435 | name: 'Portugal', 1436 | capital: 'Lisbon', 1437 | languages: ['Portuguese'], 1438 | population: 10374822, 1439 | flag: 'https://restcountries.eu/data/prt.svg', 1440 | currency: 'Euro' 1441 | }, 1442 | { 1443 | name: 'Puerto Rico', 1444 | capital: 'San Juan', 1445 | languages: ['Spanish', 'English'], 1446 | population: 3474182, 1447 | flag: 'https://restcountries.eu/data/pri.svg', 1448 | currency: 'United States dollar' 1449 | }, 1450 | { 1451 | name: 'Qatar', 1452 | capital: 'Doha', 1453 | languages: ['Arabic'], 1454 | population: 2587564, 1455 | flag: 'https://restcountries.eu/data/qat.svg', 1456 | currency: 'Qatari riyal' 1457 | }, 1458 | { 1459 | name: 'Republic of Kosovo', 1460 | capital: 'Pristina', 1461 | languages: ['Albanian', 'Serbian'], 1462 | population: 1733842, 1463 | flag: 'https://restcountries.eu/data/kos.svg', 1464 | currency: 'Euro' 1465 | }, 1466 | { 1467 | name: 'Réunion', 1468 | capital: 'Saint-Denis', 1469 | languages: ['French'], 1470 | population: 840974, 1471 | flag: 'https://restcountries.eu/data/reu.svg', 1472 | currency: 'Euro' 1473 | }, 1474 | { 1475 | name: 'Romania', 1476 | capital: 'Bucharest', 1477 | languages: ['Romanian'], 1478 | population: 19861408, 1479 | flag: 'https://restcountries.eu/data/rou.svg', 1480 | currency: 'Romanian leu' 1481 | }, 1482 | { 1483 | name: 'Russian Federation', 1484 | capital: 'Moscow', 1485 | languages: ['Russian'], 1486 | population: 146599183, 1487 | flag: 'https://restcountries.eu/data/rus.svg', 1488 | currency: 'Russian ruble' 1489 | }, 1490 | { 1491 | name: 'Rwanda', 1492 | capital: 'Kigali', 1493 | languages: ['Kinyarwanda', 'English', 'French'], 1494 | population: 11553188, 1495 | flag: 'https://restcountries.eu/data/rwa.svg', 1496 | currency: 'Rwandan franc' 1497 | }, 1498 | { 1499 | name: 'Saint Barthélemy', 1500 | capital: 'Gustavia', 1501 | languages: ['French'], 1502 | population: 9417, 1503 | flag: 'https://restcountries.eu/data/blm.svg', 1504 | currency: 'Euro' 1505 | }, 1506 | { 1507 | name: 'Saint Helena, Ascension and Tristan da Cunha', 1508 | capital: 'Jamestown', 1509 | languages: ['English'], 1510 | population: 4255, 1511 | flag: 'https://restcountries.eu/data/shn.svg', 1512 | currency: 'Saint Helena pound' 1513 | }, 1514 | { 1515 | name: 'Saint Kitts and Nevis', 1516 | capital: 'Basseterre', 1517 | languages: ['English'], 1518 | population: 46204, 1519 | flag: 'https://restcountries.eu/data/kna.svg', 1520 | currency: 'East Caribbean dollar' 1521 | }, 1522 | { 1523 | name: 'Saint Lucia', 1524 | capital: 'Castries', 1525 | languages: ['English'], 1526 | population: 186000, 1527 | flag: 'https://restcountries.eu/data/lca.svg', 1528 | currency: 'East Caribbean dollar' 1529 | }, 1530 | { 1531 | name: 'Saint Martin (French part)', 1532 | capital: 'Marigot', 1533 | languages: ['English', 'French', 'Dutch'], 1534 | population: 36979, 1535 | flag: 'https://restcountries.eu/data/maf.svg', 1536 | currency: 'Euro' 1537 | }, 1538 | { 1539 | name: 'Saint Pierre and Miquelon', 1540 | capital: 'Saint-Pierre', 1541 | languages: ['French'], 1542 | population: 6069, 1543 | flag: 'https://restcountries.eu/data/spm.svg', 1544 | currency: 'Euro' 1545 | }, 1546 | { 1547 | name: 'Saint Vincent and the Grenadines', 1548 | capital: 'Kingstown', 1549 | languages: ['English'], 1550 | population: 109991, 1551 | flag: 'https://restcountries.eu/data/vct.svg', 1552 | currency: 'East Caribbean dollar' 1553 | }, 1554 | { 1555 | name: 'Samoa', 1556 | capital: 'Apia', 1557 | languages: ['Samoan', 'English'], 1558 | population: 194899, 1559 | flag: 'https://restcountries.eu/data/wsm.svg', 1560 | currency: 'Samoan tālā' 1561 | }, 1562 | { 1563 | name: 'San Marino', 1564 | capital: 'City of San Marino', 1565 | languages: ['Italian'], 1566 | population: 33005, 1567 | flag: 'https://restcountries.eu/data/smr.svg', 1568 | currency: 'Euro' 1569 | }, 1570 | { 1571 | name: 'Sao Tome and Principe', 1572 | capital: 'São Tomé', 1573 | languages: ['Portuguese'], 1574 | population: 187356, 1575 | flag: 'https://restcountries.eu/data/stp.svg', 1576 | currency: 'São Tomé and Príncipe dobra' 1577 | }, 1578 | { 1579 | name: 'Saudi Arabia', 1580 | capital: 'Riyadh', 1581 | languages: ['Arabic'], 1582 | population: 32248200, 1583 | flag: 'https://restcountries.eu/data/sau.svg', 1584 | currency: 'Saudi riyal' 1585 | }, 1586 | { 1587 | name: 'Senegal', 1588 | capital: 'Dakar', 1589 | languages: ['French'], 1590 | population: 14799859, 1591 | flag: 'https://restcountries.eu/data/sen.svg', 1592 | currency: 'West African CFA franc' 1593 | }, 1594 | { 1595 | name: 'Serbia', 1596 | capital: 'Belgrade', 1597 | languages: ['Serbian'], 1598 | population: 7076372, 1599 | flag: 'https://restcountries.eu/data/srb.svg', 1600 | currency: 'Serbian dinar' 1601 | }, 1602 | { 1603 | name: 'Seychelles', 1604 | capital: 'Victoria', 1605 | languages: ['French', 'English'], 1606 | population: 91400, 1607 | flag: 'https://restcountries.eu/data/syc.svg', 1608 | currency: 'Seychellois rupee' 1609 | }, 1610 | { 1611 | name: 'Sierra Leone', 1612 | capital: 'Freetown', 1613 | languages: ['English'], 1614 | population: 7075641, 1615 | flag: 'https://restcountries.eu/data/sle.svg', 1616 | currency: 'Sierra Leonean leone' 1617 | }, 1618 | { 1619 | name: 'Singapore', 1620 | capital: 'Singapore', 1621 | languages: ['English', 'Malay', 'Tamil', 'Chinese'], 1622 | population: 5535000, 1623 | flag: 'https://restcountries.eu/data/sgp.svg', 1624 | currency: 'Brunei dollar' 1625 | }, 1626 | { 1627 | name: 'Sint Maarten (Dutch part)', 1628 | capital: 'Philipsburg', 1629 | languages: ['Dutch', 'English'], 1630 | population: 38247, 1631 | flag: 'https://restcountries.eu/data/sxm.svg', 1632 | currency: 'Netherlands Antillean guilder' 1633 | }, 1634 | { 1635 | name: 'Slovakia', 1636 | capital: 'Bratislava', 1637 | languages: ['Slovak'], 1638 | population: 5426252, 1639 | flag: 'https://restcountries.eu/data/svk.svg', 1640 | currency: 'Euro' 1641 | }, 1642 | { 1643 | name: 'Slovenia', 1644 | capital: 'Ljubljana', 1645 | languages: ['Slovene'], 1646 | population: 2064188, 1647 | flag: 'https://restcountries.eu/data/svn.svg', 1648 | currency: 'Euro' 1649 | }, 1650 | { 1651 | name: 'Solomon Islands', 1652 | capital: 'Honiara', 1653 | languages: ['English'], 1654 | population: 642000, 1655 | flag: 'https://restcountries.eu/data/slb.svg', 1656 | currency: 'Solomon Islands dollar' 1657 | }, 1658 | { 1659 | name: 'Somalia', 1660 | capital: 'Mogadishu', 1661 | languages: ['Somali', 'Arabic'], 1662 | population: 11079000, 1663 | flag: 'https://restcountries.eu/data/som.svg', 1664 | currency: 'Somali shilling' 1665 | }, 1666 | { 1667 | name: 'South Africa', 1668 | capital: 'Pretoria', 1669 | languages: [ 1670 | 'Afrikaans', 1671 | 'English', 1672 | 'Southern Ndebele', 1673 | 'Southern Sotho', 1674 | 'Swati', 1675 | 'Tswana', 1676 | 'Tsonga', 1677 | 'Venda', 1678 | 'Xhosa', 1679 | 'Zulu' 1680 | ], 1681 | population: 55653654, 1682 | flag: 'https://restcountries.eu/data/zaf.svg', 1683 | currency: 'South African rand' 1684 | }, 1685 | { 1686 | name: 'South Georgia and the South Sandwich Islands', 1687 | capital: 'King Edward Point', 1688 | languages: ['English'], 1689 | population: 30, 1690 | flag: 'https://restcountries.eu/data/sgs.svg', 1691 | currency: 'British pound' 1692 | }, 1693 | { 1694 | name: 'Korea (Republic of)', 1695 | capital: 'Seoul', 1696 | languages: ['Korean'], 1697 | population: 50801405, 1698 | flag: 'https://restcountries.eu/data/kor.svg', 1699 | currency: 'South Korean won' 1700 | }, 1701 | { 1702 | name: 'South Sudan', 1703 | capital: 'Juba', 1704 | languages: ['English'], 1705 | population: 12131000, 1706 | flag: 'https://restcountries.eu/data/ssd.svg', 1707 | currency: 'South Sudanese pound' 1708 | }, 1709 | { 1710 | name: 'Spain', 1711 | capital: 'Madrid', 1712 | languages: ['Spanish'], 1713 | population: 46438422, 1714 | flag: 'https://restcountries.eu/data/esp.svg', 1715 | currency: 'Euro' 1716 | }, 1717 | { 1718 | name: 'Sri Lanka', 1719 | capital: 'Colombo', 1720 | languages: ['Sinhalese', 'Tamil'], 1721 | population: 20966000, 1722 | flag: 'https://restcountries.eu/data/lka.svg', 1723 | currency: 'Sri Lankan rupee' 1724 | }, 1725 | { 1726 | name: 'Sudan', 1727 | capital: 'Khartoum', 1728 | languages: ['Arabic', 'English'], 1729 | population: 39598700, 1730 | flag: 'https://restcountries.eu/data/sdn.svg', 1731 | currency: 'Sudanese pound' 1732 | }, 1733 | { 1734 | name: 'Suriname', 1735 | capital: 'Paramaribo', 1736 | languages: ['Dutch'], 1737 | population: 541638, 1738 | flag: 'https://restcountries.eu/data/sur.svg', 1739 | currency: 'Surinamese dollar' 1740 | }, 1741 | { 1742 | name: 'Svalbard and Jan Mayen', 1743 | capital: 'Longyearbyen', 1744 | languages: ['Norwegian'], 1745 | population: 2562, 1746 | flag: 'https://restcountries.eu/data/sjm.svg', 1747 | currency: 'Norwegian krone' 1748 | }, 1749 | { 1750 | name: 'Swaziland', 1751 | capital: 'Lobamba', 1752 | languages: ['English', 'Swati'], 1753 | population: 1132657, 1754 | flag: 'https://restcountries.eu/data/swz.svg', 1755 | currency: 'Swazi lilangeni' 1756 | }, 1757 | { 1758 | name: 'Sweden', 1759 | capital: 'Stockholm', 1760 | languages: ['Swedish'], 1761 | population: 9894888, 1762 | flag: 'https://restcountries.eu/data/swe.svg', 1763 | currency: 'Swedish krona' 1764 | }, 1765 | { 1766 | name: 'Switzerland', 1767 | capital: 'Bern', 1768 | languages: ['German', 'French', 'Italian'], 1769 | population: 8341600, 1770 | flag: 'https://restcountries.eu/data/che.svg', 1771 | currency: 'Swiss franc' 1772 | }, 1773 | { 1774 | name: 'Syrian Arab Republic', 1775 | capital: 'Damascus', 1776 | languages: ['Arabic'], 1777 | population: 18564000, 1778 | flag: 'https://restcountries.eu/data/syr.svg', 1779 | currency: 'Syrian pound' 1780 | }, 1781 | { 1782 | name: 'Taiwan', 1783 | capital: 'Taipei', 1784 | languages: ['Chinese'], 1785 | population: 23503349, 1786 | flag: 'https://restcountries.eu/data/twn.svg', 1787 | currency: 'New Taiwan dollar' 1788 | }, 1789 | { 1790 | name: 'Tajikistan', 1791 | capital: 'Dushanbe', 1792 | languages: ['Tajik', 'Russian'], 1793 | population: 8593600, 1794 | flag: 'https://restcountries.eu/data/tjk.svg', 1795 | currency: 'Tajikistani somoni' 1796 | }, 1797 | { 1798 | name: 'Tanzania, United Republic of', 1799 | capital: 'Dodoma', 1800 | languages: ['Swahili', 'English'], 1801 | population: 55155000, 1802 | flag: 'https://restcountries.eu/data/tza.svg', 1803 | currency: 'Tanzanian shilling' 1804 | }, 1805 | { 1806 | name: 'Thailand', 1807 | capital: 'Bangkok', 1808 | languages: ['Thai'], 1809 | population: 65327652, 1810 | flag: 'https://restcountries.eu/data/tha.svg', 1811 | currency: 'Thai baht' 1812 | }, 1813 | { 1814 | name: 'Timor-Leste', 1815 | capital: 'Dili', 1816 | languages: ['Portuguese'], 1817 | population: 1167242, 1818 | flag: 'https://restcountries.eu/data/tls.svg', 1819 | currency: 'United States dollar' 1820 | }, 1821 | { 1822 | name: 'Togo', 1823 | capital: 'Lomé', 1824 | languages: ['French'], 1825 | population: 7143000, 1826 | flag: 'https://restcountries.eu/data/tgo.svg', 1827 | currency: 'West African CFA franc' 1828 | }, 1829 | { 1830 | name: 'Tokelau', 1831 | capital: 'Fakaofo', 1832 | languages: ['English'], 1833 | population: 1411, 1834 | flag: 'https://restcountries.eu/data/tkl.svg', 1835 | currency: 'New Zealand dollar' 1836 | }, 1837 | { 1838 | name: 'Tonga', 1839 | capital: "Nuku'alofa", 1840 | languages: ['English', 'Tonga (Tonga Islands)'], 1841 | population: 103252, 1842 | flag: 'https://restcountries.eu/data/ton.svg', 1843 | currency: 'Tongan paʻanga' 1844 | }, 1845 | { 1846 | name: 'Trinidad and Tobago', 1847 | capital: 'Port of Spain', 1848 | languages: ['English'], 1849 | population: 1349667, 1850 | flag: 'https://restcountries.eu/data/tto.svg', 1851 | currency: 'Trinidad and Tobago dollar' 1852 | }, 1853 | { 1854 | name: 'Tunisia', 1855 | capital: 'Tunis', 1856 | languages: ['Arabic'], 1857 | population: 11154400, 1858 | flag: 'https://restcountries.eu/data/tun.svg', 1859 | currency: 'Tunisian dinar' 1860 | }, 1861 | { 1862 | name: 'Turkey', 1863 | capital: 'Ankara', 1864 | languages: ['Turkish'], 1865 | population: 78741053, 1866 | flag: 'https://restcountries.eu/data/tur.svg', 1867 | currency: 'Turkish lira' 1868 | }, 1869 | { 1870 | name: 'Turkmenistan', 1871 | capital: 'Ashgabat', 1872 | languages: ['Turkmen', 'Russian'], 1873 | population: 4751120, 1874 | flag: 'https://restcountries.eu/data/tkm.svg', 1875 | currency: 'Turkmenistan manat' 1876 | }, 1877 | { 1878 | name: 'Turks and Caicos Islands', 1879 | capital: 'Cockburn Town', 1880 | languages: ['English'], 1881 | population: 31458, 1882 | flag: 'https://restcountries.eu/data/tca.svg', 1883 | currency: 'United States dollar' 1884 | }, 1885 | { 1886 | name: 'Tuvalu', 1887 | capital: 'Funafuti', 1888 | languages: ['English'], 1889 | population: 10640, 1890 | flag: 'https://restcountries.eu/data/tuv.svg', 1891 | currency: 'Australian dollar' 1892 | }, 1893 | { 1894 | name: 'Uganda', 1895 | capital: 'Kampala', 1896 | languages: ['English', 'Swahili'], 1897 | population: 33860700, 1898 | flag: 'https://restcountries.eu/data/uga.svg', 1899 | currency: 'Ugandan shilling' 1900 | }, 1901 | { 1902 | name: 'Ukraine', 1903 | capital: 'Kiev', 1904 | languages: ['Ukrainian'], 1905 | population: 42692393, 1906 | flag: 'https://restcountries.eu/data/ukr.svg', 1907 | currency: 'Ukrainian hryvnia' 1908 | }, 1909 | { 1910 | name: 'United Arab Emirates', 1911 | capital: 'Abu Dhabi', 1912 | languages: ['Arabic'], 1913 | population: 9856000, 1914 | flag: 'https://restcountries.eu/data/are.svg', 1915 | currency: 'United Arab Emirates dirham' 1916 | }, 1917 | { 1918 | name: 'United Kingdom of Great Britain and Northern Ireland', 1919 | capital: 'London', 1920 | languages: ['English'], 1921 | population: 65110000, 1922 | flag: 'https://restcountries.eu/data/gbr.svg', 1923 | currency: 'British pound' 1924 | }, 1925 | { 1926 | name: 'United States of America', 1927 | capital: 'Washington, D.C.', 1928 | languages: ['English'], 1929 | population: 323947000, 1930 | flag: 'https://restcountries.eu/data/usa.svg', 1931 | currency: 'United States dollar' 1932 | }, 1933 | { 1934 | name: 'Uruguay', 1935 | capital: 'Montevideo', 1936 | languages: ['Spanish'], 1937 | population: 3480222, 1938 | flag: 'https://restcountries.eu/data/ury.svg', 1939 | currency: 'Uruguayan peso' 1940 | }, 1941 | { 1942 | name: 'Uzbekistan', 1943 | capital: 'Tashkent', 1944 | languages: ['Uzbek', 'Russian'], 1945 | population: 31576400, 1946 | flag: 'https://restcountries.eu/data/uzb.svg', 1947 | currency: "Uzbekistani so'm" 1948 | }, 1949 | { 1950 | name: 'Vanuatu', 1951 | capital: 'Port Vila', 1952 | languages: ['Bislama', 'English', 'French'], 1953 | population: 277500, 1954 | flag: 'https://restcountries.eu/data/vut.svg', 1955 | currency: 'Vanuatu vatu' 1956 | }, 1957 | { 1958 | name: 'Venezuela (Bolivarian Republic of)', 1959 | capital: 'Caracas', 1960 | languages: ['Spanish'], 1961 | population: 31028700, 1962 | flag: 'https://restcountries.eu/data/ven.svg', 1963 | currency: 'Venezuelan bolívar' 1964 | }, 1965 | { 1966 | name: 'Viet Nam', 1967 | capital: 'Hanoi', 1968 | languages: ['Vietnamese'], 1969 | population: 92700000, 1970 | flag: 'https://restcountries.eu/data/vnm.svg', 1971 | currency: 'Vietnamese đồng' 1972 | }, 1973 | { 1974 | name: 'Wallis and Futuna', 1975 | capital: 'Mata-Utu', 1976 | languages: ['French'], 1977 | population: 11750, 1978 | flag: 'https://restcountries.eu/data/wlf.svg', 1979 | currency: 'CFP franc' 1980 | }, 1981 | { 1982 | name: 'Western Sahara', 1983 | capital: 'El Aaiún', 1984 | languages: ['Spanish'], 1985 | population: 510713, 1986 | flag: 'https://restcountries.eu/data/esh.svg', 1987 | currency: 'Moroccan dirham' 1988 | }, 1989 | { 1990 | name: 'Yemen', 1991 | capital: "Sana'a", 1992 | languages: ['Arabic'], 1993 | population: 27478000, 1994 | flag: 'https://restcountries.eu/data/yem.svg', 1995 | currency: 'Yemeni rial' 1996 | }, 1997 | { 1998 | name: 'Zambia', 1999 | capital: 'Lusaka', 2000 | languages: ['English'], 2001 | population: 15933883, 2002 | flag: 'https://restcountries.eu/data/zmb.svg', 2003 | currency: 'Zambian kwacha' 2004 | }, 2005 | { 2006 | name: 'Zimbabwe', 2007 | capital: 'Harare', 2008 | languages: ['English', 'Shona', 'Northern Ndebele'], 2009 | population: 14240168, 2010 | flag: 'https://restcountries.eu/data/zwe.svg', 2011 | currency: 'Botswana pula' 2012 | } 2013 | ] 2014 | 2015 | 2016 | -------------------------------------------------------------------------------- /Day08_Objects/level1.js: -------------------------------------------------------------------------------- 1 | // LEVEL 1: Objects 2 | // 1 3 | const dog = {}; 4 | 5 | // 2 6 | console.log(dog); 7 | 8 | // 3 9 | dog['name'] = 'Barky'; 10 | dog['age'] = 2; 11 | dog['legs'] = 4; 12 | dog['color']= 'red'; 13 | dog['bark'] = () => 'Woof Woof'; 14 | 15 | // 4 16 | console.log(dog.name, dog.legs, dog.color, dog.age, dog.bark()); 17 | 18 | // 5 19 | dog['breed'] = 'German shepherd'; 20 | dog['getDogInfo'] = () => { 21 | console.log(dog.name); 22 | console.log(dog.age); 23 | console.log(dog.breed); 24 | } 25 | dog.getDogInfo(); 26 | 27 | // ** LEVEL 1 Completed **/ 28 | -------------------------------------------------------------------------------- /Day08_Objects/level2.js: -------------------------------------------------------------------------------- 1 | /** LEVEL 2: Objects **/ 2 | const users = { 3 | Alex : { 4 | email:'alex@alex.com', 5 | skills:['HTML','CSS','JavaScript'], 6 | age:20, 7 | isLoggedIn:false, 8 | points:30 9 | }, 10 | Asab:{ 11 | email:'asab@asab.com', 12 | skills:['HTML','CSS','JavaScript','Redux','MongoDB','Express','React','Node'], 13 | age:25, 14 | isLoggedIn:false, 15 | points:50 16 | }, 17 | Brook:{ 18 | email:'daniel@daniel.com', 19 | skills:['HTML','CSS','JavaScript','React','Redux'], 20 | age:30, 21 | isLoggedIn:true, 22 | points:50 23 | }, 24 | Daniel:{ 25 | email:'daniel@alex.com', 26 | skills:['HTML','CSS','JavaScript','Python'], 27 | age:20, 28 | isLoggedIn:false, 29 | points:40 30 | }, 31 | John:{ 32 | email:'john@john.com', 33 | skills:['HTML','CSS','JavaScript','React','Redux','Node.js'], 34 | age:20, 35 | isLoggedIn:true, 36 | points:50 37 | }, 38 | Thomas:{ 39 | email:'thomas@thomas.com', 40 | skills:['HTML','CSS','JavaScript','React'], 41 | age:20, 42 | isLoggedIn:false, 43 | points:40 44 | }, 45 | Paul:{ 46 | email:'paul@paul.com', 47 | skills:['HTML','CSS','JavaScript','MongoDB','Express','React','Node'], 48 | age:20, 49 | isLoggedIn:false, 50 | points:40 51 | } 52 | } 53 | 54 | // 1 55 | let max = 0; 56 | let skilledPerson; 57 | 58 | for(const user of Object.keys(users)) { 59 | if(users[user].skills.length > max) { 60 | max = users[user].skills.length; 61 | skilledPerson = Object.assign({}, users[user]); 62 | } 63 | } 64 | console.log(skilledPerson.email, max); 65 | 66 | // 2 67 | let loggedInUsers = 0; 68 | let points50UpUsers = 0; 69 | 70 | for(const user of Object.keys(users)) { 71 | if(users[user].isLoggedIn) 72 | loggedInUsers++; 73 | 74 | if(users[user].points >= 50) 75 | points50UpUsers++; 76 | } 77 | console.log(loggedInUsers, points50UpUsers); 78 | 79 | // 3 : Find Mern Stack Developers 80 | let findMernStackDevs = () => { 81 | let mern = ['MangoDB', 'Express', 'React', 'Node']; 82 | let count = 0; 83 | let mernStackDevs = []; 84 | 85 | for(const dev of Object.values(users)) { 86 | for(const skill of dev['skills']) { 87 | if (mern.indexOf(skill) != -1) 88 | count++; 89 | } 90 | if(count == 4) 91 | mernStackDevs.push(dev); 92 | } 93 | return mernStackDevs; 94 | } 95 | 96 | findMernStackDevs().forEach((el) => { 97 | console.log(el); 98 | }) 99 | 100 | // 4 101 | const usersCopy = Object.assign({}, users); 102 | usersCopy['Hamza'] = {}; 103 | 104 | // 5 105 | const keys = Object.keys(users); 106 | 107 | // 6 108 | const values = Object.values(users); 109 | 110 | // 7: Countries.js files should be availed 111 | const country = countries[Object.keys(countries)[0]]; 112 | 113 | console.log("Name: ", country.name) 114 | console.log("Capital: ", country.capital) 115 | console.log("Population: ", country.population); 116 | console.log("Languages: ", country.languages); 117 | 118 | /** LEVEL 2 Completed **/ 119 | -------------------------------------------------------------------------------- /Day08_Objects/level3.js: -------------------------------------------------------------------------------- 1 | /** LEVEL 3 Challenges: Objects **/ 2 | // 1 3 | const personAccount = { 4 | firstName: 'John', 5 | lastName: 'Nash', 6 | balance: 0, 7 | 8 | incomes: { 9 | courses: 2000, 10 | salary: 2300, 11 | tutoring: 1800 12 | }, 13 | expenses: { 14 | rent: 1200, 15 | bill: 400, 16 | saloon: 150 17 | }, 18 | 19 | // methods down below 20 | totalIncome: function(){ 21 | let total = 0; 22 | for(const each of Object.keys(personAccount.incomes)) 23 | total += personAccount.incomes[each]; 24 | return total; 25 | }, 26 | 27 | totalExpense: function() { 28 | let total = 0; 29 | for(const each of Object.values(personAccount.expenses)) { 30 | total += each; 31 | } 32 | return total; 33 | }, 34 | 35 | 36 | // account balance 37 | accountBalance : function() { 38 | return this.balance; 39 | }, 40 | 41 | accountInfo : function() { 42 | console.log("Name: ", this.firstName + ' ' + this.lastName); 43 | console.log("Account Balance: ", this.balance); 44 | }, 45 | 46 | addIncome : function(type, amount) { 47 | this.incomes[type] = amount; 48 | }, 49 | 50 | addExpense : function(type, amount) { 51 | this.expenses[type] = amount; 52 | } 53 | } 54 | 55 | 56 | console.log(personAccount.totalIncome()); 57 | console.log(personAccount.totalExpense()); 58 | personAccount.accountInfo(); 59 | personAccount.addIncome('art', 200); 60 | personAccount.addExpense('pen', 330); 61 | personAccount.accountInfo(); 62 | 63 | // 2 : user_pdt.js is required here 64 | // i 65 | let signUP = (name, mail, pswd) => { 66 | // check if user exists 67 | for(const usr of users) 68 | if(usr.mail == mail) 69 | return 'User Exists!'; 70 | 71 | // generate ID first 72 | let alps = '123456abhsgesvj2672sa'; 73 | let rand = []; 74 | 75 | for(const chr of '______') { 76 | let random = parseInt(Math.random()*alps.length); 77 | rand.push(alps[random]); 78 | } 79 | let id = rand.join(''); 80 | 81 | // create the date 82 | const d = new Date(); 83 | 84 | let mins = d.getMinutes(); 85 | mins < 10 ? '0' + mins.toString() : mins; 86 | let hrs = d.getHours(); 87 | hrs < 10 ? '0' + hrs.toString() : hrs; 88 | 89 | let year = d.getFullYear(); 90 | let month = d.getMonth(); 91 | let date = d.getDate(); 92 | 93 | let DATE = `${year}/${month+1}/${date} ${hrs>12? (hrs-12).toString() + ':' + mins.toString() + ' PM': hrs.toString()+':' + mins.toString() + ' AM'}`; 94 | 95 | // add to the object of users 96 | let userData = { 97 | _id: id, 98 | username: name, 99 | email: mail, 100 | password: pswd, 101 | createdAt: DATE, 102 | isLoggedIn: false 103 | }; 104 | users.push(userData); 105 | } 106 | signUP('alecy', 'aex@alex.com', 'pstg34'); 107 | 108 | users.forEach((x) => console.log(x)); 109 | // ii: SignIN 110 | let signIN = (mail, pswd) => { 111 | for(const user of users) { 112 | if(user.email == mail && user.password == pswd) { 113 | user.isLoggedIn = true; 114 | return 'You have been signed in!!'; 115 | } 116 | } 117 | return 'Incorrect Email or password'; 118 | } 119 | console.log(signIN('alex@alex.com', '123123')) 120 | // 3 121 | // i 122 | let rateProduct = (productNum, userId, rate) => { 123 | let theRating = {'userId': userId, 'rate': rate}; 124 | products[productNum-1].ratings.push(theRating); 125 | console.log(products[productNum-1].ratings); 126 | } 127 | rateProduct(2, '23sdf2', 4); 128 | 129 | // ii 130 | let averageRating = (productID) => { 131 | let total = 0; 132 | let pdt; 133 | 134 | for(const prod of products) { 135 | if(prod._id == productID) 136 | pdt = prod; 137 | } 138 | 139 | for(const usr of pdt.ratings) { 140 | total += usr.rate; 141 | } 142 | return total/pdt.ratings.length; 143 | } 144 | console.log(averageRating('eedfcf')); 145 | 146 | // 4 147 | let likeProduct = (userId, productNo) => { 148 | let pdt = products[productNo-1]; 149 | let index = pdt.likes.indexOf(userId); 150 | 151 | if(index == -1) { 152 | pdt.likes.push(userId); 153 | } 154 | else { 155 | pdt.likes.splice(index, 1); 156 | } 157 | } 158 | 159 | likeProduct('venom23', 1); 160 | 161 | // LEVEL 3 Challenges Completed 162 | -------------------------------------------------------------------------------- /Day09_High_Order_Functions/level1.js: -------------------------------------------------------------------------------- 1 | /** LEVEL 1 Challenges **/ 2 | // 1. Difference b/w callback, map, filter, reduce 3 | // callback 4 | /**callback is a higher order first class function in JS which is being passed to a function. It is used by the function it is being passed to perform certain operations on the object. 5 | **/ 6 | 7 | // forEach 8 | /** 9 | It is the defacto function defined in the iterable objects in JS which takes a callback and applies it to each element of iterable. It is often used in place of for loops if somone is not interested in the index of the loop. 10 | **/ 11 | // map 12 | /** map is higher order function in JS which takes a callback and apply it to each element of the iterable it is called upon. It returns a new iterable that is the modified version of the one it is called upon. 13 | **/ 14 | 15 | // filter 16 | /** filter is a also a HO-FC function defined by the iterable objects in JS. It takes a callback and applies it to each element of the iterable, the callback if returns true, it returns the element otherwise drops it. It is used to filter objects based on some condition. 17 | **/ 18 | 19 | // reduce 20 | /** reduce takes a callback, it takes a callback function which in turn takes two arguments - accumulator, and current_value, and it takes an optional but recommended second argument - intial value. 21 | * ...working .... 22 | * the reduce function initializes the accumulator with initial_value if provided, zero otherwise and applies the callback on each element of iterable. on each iteration, the current_values is added (depends upon the operation) to accumulator and stored in the accumulator. When all iterations are completed, the reduce returns a single value which is result of all numerical operations done on values of the iterable. 23 | **/ 24 | const countries = ['Finland', 'Sweden', 'Denmark', 'Norway', 'IceLand'] 25 | const names = ['Asabeneh', 'Mathias', 'Elias', 'Brook'] 26 | const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 27 | const products = [ 28 | { product: 'banana', price: 3 }, 29 | { product: 'mango', price: 6 }, 30 | { product: 'potato', price: ' ' }, 31 | { product: 'avocado', price: 8 }, 32 | { product: 'coffee', price: 10 }, 33 | { product: 'tea', price: '' }, 34 | ] 35 | 36 | // 3 37 | countries.forEach(c => console.log(c)); 38 | // 4 39 | names.forEach(n => console.log(n)); 40 | // 5 41 | numbers.forEach(n => console.log(n)); 42 | // 6 43 | const capCountries = countries.map(c => c.toUpperCase()); 44 | // 7 45 | const countriesLen = countries.map(c => c.length); 46 | // 8 47 | const squaredLens = countriesLen.map(n=>n*n); 48 | console.log(squaredLens); 49 | 50 | // 9 51 | const capNames = names.map(n => n.toUpperCase()); 52 | // 10 53 | const prices = products.map(p => p.price); 54 | // 11 55 | const withLand = countries.filter(c => c.toLowerCase().includes('land')); 56 | // 12 57 | const exactlySixChars = countries.filter(c => c.length === 6); 58 | // 13 59 | const sixOrMoreChars= countries.filter(c => c.length > 5); 60 | // 14 61 | const startsWithE = countries.filter(c => c.startsWith('E')); 62 | 63 | // 15 64 | const validPrices = products.filter(p => { 65 | return typeof p.price != 'string' 66 | }) 67 | // 16 68 | let getStringLists = (arr) => { 69 | return arr.filter(elem => typeof elem == 'string'); 70 | } 71 | let a = [1, 2 , 'sdf', 'sdf', 234]; 72 | console.log(getStringLists(a)); 73 | // 17 74 | let arr = [1, 2, 34, 323]; 75 | const sumOfArr = arr.reduce((acc, cur) => acc + cur, 0); 76 | console.log(sumOfArr); 77 | 78 | // 18 79 | // 19: some vs. every 80 | /** some -> returns true if at least one of the element of an iterable satisfies the condition imposed by the callback, false if none do. 81 | 82 | every -> returns treu if all the valeus of iterable satisfy the condition imposed by callback, returns false if none at least no does not satisfy it. 83 | **/ 84 | // 20 85 | const namesWith6orMoreLen = names.some(n => n.length > 7); 86 | console.log(namesWith6orMoreLen); 87 | // 21 88 | let allContainLand = countries.every(c => c.toLowerCase().includes('land')); 89 | 90 | // 22: Difference between 'find' and 'findIndex' 91 | /** 92 | find -> applies a callback to each element of an iterable and returns the first element that satisfies the callback condition 93 | findIndex -> does the same but returns the index of the object instead of the object itself. 94 | **/ 95 | 96 | // 23 97 | let sixCharsCountry = countries.find(c => c.length === 6); 98 | 99 | // 24 100 | let indexOfSixCharsCountry = countries.findIndex(c => c.length === 6); 101 | 102 | // 25 103 | let indexOfNorway = countries.findIndex(c => c === 'Norway'); 104 | 105 | // 26 106 | let indexOfRussia = countries.findIndex(c => c === 'Russia'); 107 | 108 | // END OF CHALLENGE LEVEL 1 109 | -------------------------------------------------------------------------------- /Day09_High_Order_Functions/level2.js: -------------------------------------------------------------------------------- 1 | // LEVEL 2: Higher Order Functions in JS 2 | /** REQUIRED DATA **/ 3 | const countries = ['Finland', 'Sweden', 'Denmark', 'Norway', 'IceLand'] 4 | const names = ['Asabeneh', 'Mathias', 'Elias', 'Brook'] 5 | const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 6 | const products = [ 7 | { product: 'banana', price: 3 }, 8 | { product: 'mango', price: 6 }, 9 | { product: 'potato', price: ' ' }, 10 | { product: 'avocado', price: 8 }, 11 | { product: 'coffee', price: 10 }, 12 | { product: 'tea', price: '' }, 13 | ] 14 | 15 | // 1 16 | let totalPrice = products.filter(p => typeof p.price != 'string').reduce((acc, cur) => acc + cur.price, 0); 17 | 18 | // 2: use only reduce here 19 | let totalPrice2 = products.reduce((sum, obj) => { return typeof obj.price != 'string' ? sum += obj.price: sum; 20 | }, 0); 21 | 22 | // 3 23 | let categorizeCountries = (arr) => { 24 | return arr.filter(c => c.endsWith('en')); 25 | } 26 | 27 | // 4 28 | let frequentLetterList = Countries.map(c => c[0]).reduce((obj, cur) => { 29 | obj[cur] = (obj[cur] || 0) +1; 30 | return obj; 31 | }, {}) 32 | console.log(frequentLetterList); 33 | /** 34 | function getObject(arr) { 35 | let object = {}; 36 | for(const i of arr) { 37 | if(object.hasOwnProperty(i)) { 38 | object[i] += 1; 39 | } 40 | else { 41 | object[i] = 1; 42 | } 43 | } 44 | return object; 45 | } 46 | console.log(getObject(frequentLetter)); 47 | **/ 48 | // 5: get first 10 countries 49 | let getFirstTenCountries = arr => arr.filter(c => arr.indexOf(c)<10); 50 | 51 | // 6: get last 10 countries 52 | let getLastTenCountries = arr => arr.filter(c=> arr.indexOf(c) > arr.length-11); 53 | 54 | // 7 : find out whic letter is used the most 55 | let frequentFirstLetter = Object.entries(Countries.map(c => c[0]).reduce((acc,cur) => { 56 | acc[cur] = (acc[cur] || 0) +1; 57 | return acc; 58 | }, {})).reduce((obj, cur) => { 59 | obj.max = (obj.max || cur[1]); 60 | obj.letter = (obj.letter || ''); 61 | 62 | if (obj.max < cur[1]) { 63 | obj.max = cur[1]; 64 | obj.letter = cur[0]; 65 | } 66 | return obj; 67 | }, {}).letter; 68 | 69 | console.log(frequentFirstLetter); 70 | // { [1, 2]: [2, 4 ]} 71 | 72 | // END of LEVEL 2 73 | -------------------------------------------------------------------------------- /Day09_High_Order_Functions/level3.js: -------------------------------------------------------------------------------- 1 | // LEVEL 3 Challenges| Functional Programming 2 | // data 3 | const countries = [ 4 | { 5 | name: 'Afghanistan', 6 | capital: 'Kabul', 7 | languages: ['Pashto', 'Uzbek', 'Turkmen'], 8 | population: 27657145, 9 | flag: 'https://restcountries.eu/data/afg.svg', 10 | currency: 'Afghan afghani' 11 | }, 12 | { 13 | name: 'Åland Islands', 14 | capital: 'Mariehamn', 15 | languages: ['Swedish'], 16 | population: 28875, 17 | flag: 'https://restcountries.eu/data/ala.svg', 18 | currency: 'Euro' 19 | }, 20 | { 21 | name: 'Albania', 22 | capital: 'Tirana', 23 | languages: ['Albanian'], 24 | population: 2886026, 25 | flag: 'https://restcountries.eu/data/alb.svg', 26 | currency: 'Albanian lek' 27 | }, 28 | { 29 | name: 'Algeria', 30 | capital: 'Algiers', 31 | languages: ['Arabic'], 32 | population: 40400000, 33 | flag: 'https://restcountries.eu/data/dza.svg', 34 | currency: 'Algerian dinar' 35 | }, 36 | { 37 | name: 'American Samoa', 38 | capital: 'Pago Pago', 39 | languages: ['English', 'Samoan'], 40 | population: 57100, 41 | flag: 'https://restcountries.eu/data/asm.svg', 42 | currency: 'United State Dollar' 43 | }, 44 | { 45 | name: 'Andorra', 46 | capital: 'Andorra la Vella', 47 | languages: ['Catalan'], 48 | population: 78014, 49 | flag: 'https://restcountries.eu/data/and.svg', 50 | currency: 'Euro' 51 | }] 52 | // 1(a): sort by name 53 | let sortedByName = countries.map(o => o.name ); 54 | sortedByName.forEach(x =>console.log(x)); 55 | 56 | // 1(b): sort by capital 57 | let sortedByCapital = countries.sort((a, b) => a.capital.localeCompare(b.capital)); 58 | sortedByCapital.forEach(o=>console.log(o)); 59 | 60 | // 1(c): sort by population 61 | let sortedByPopulation = countries.sort((a, b) => b.population - a.population); 62 | sortedByPopulation.forEach(x => console.log(x)); 63 | 64 | // 2: get top 10 spoken languages 65 | // makes langs array 66 | let mostSpoken = Object.entries(countries.reduce((langs, obj) => { obj.languages.forEach(x => langs.push(x)); 67 | return langs; 68 | }, []).reduce((dict, lang) => { 69 | dict[lang] = (dict[lang] || 0) +1; 70 | return dict; 71 | }, {})).sort((a, b) => b[1]-a[1]); 72 | mostSpoken.forEach(x => console.log(x)); 73 | 74 | // 75 | function sortByMostPopulated (countries) { 76 | let mostPopulated = countries.sort((a, b) => b.population - a.population); 77 | return mostPopulated; 78 | } 79 | 80 | // LEVEL 3 Ended 81 | -------------------------------------------------------------------------------- /Day10_Maps_Sets/level1.js: -------------------------------------------------------------------------------- 1 | // LEVEL 1: Sets and Maps basics 2 | let countries = ['Pakistan', 'India', 'Afghanistan', 'Iran', 'Turkey']; 3 | 4 | // 1: create empty set 5 | let empty = new Set(); 6 | 7 | // 2: 0-10 using loop in set 8 | let arr = [0,1,2,3,4,5,6,7,8,9,10]; 9 | let anotherSet = new Set(); 10 | for(const n of arr) { 11 | anotherSet.add(n); 12 | } 13 | 14 | // 3: remove an element 15 | anotherSet.delete(2); 16 | 17 | // 4: clear the set 18 | anotherSet.clear(); 19 | 20 | // 5: set of 5 string elements 21 | let setOfCountries = new Set(countries); 22 | setOfCountries.forEach(o => console.log(o)) 23 | 24 | // 6: Create Map of countries and length of their names 25 | let mapOfCountries = new Map(); 26 | for(const country of countries) { 27 | mapOfCountries.set(country, country.length); 28 | } 29 | 30 | // * Complete 31 | -------------------------------------------------------------------------------- /Day10_Maps_Sets/level2.js: -------------------------------------------------------------------------------- 1 | // LEVEL 2: intermediate Sets and Maps 2 | const a = [4, 5, 8, 9]; 3 | const b = [3, 4, 5, 7]; 4 | 5 | // 1: Find AUB 6 | const c = [...a, ...b]; 7 | let aUnionB = new Set(c); 8 | 9 | // 2: A Intersection B 10 | let A = new Set(a); 11 | let B = new Set(b); 12 | 13 | let x = a.filter(e => B.has(e)); 14 | let C = new Set(x); 15 | C.forEach(x => console.log(x)); 16 | 17 | // 3: Find a difference b 18 | let result = a.filter(x => !B.has(x)); 19 | let aDiffB = new Set(result); 20 | aDiffB.forEach(x => console.log(x)); 21 | 22 | // LEVEL 2 complete 23 | -------------------------------------------------------------------------------- /Day10_Maps_Sets/level3.js: -------------------------------------------------------------------------------- 1 | // Level 3: challenge 2 | // 1: 3 | let count = (new Set(countries.reduce((arr, cur) => { 4 | arr = arr.concat(cur.languages); 5 | return arr; 6 | }, []))).size; 7 | console.log(count); 8 | 9 | // 2: cur is object or country 10 | let mostSpoken = new Set(Object.entries(countries.reduce((arr, obj) => (arr = arr.concat(obj.languages)), []).reduce((obj, name) => { 11 | obj[name] = (obj[name] || 0) +1; 12 | return obj; 13 | }, {}))); 14 | 15 | // Completed Level 3 16 | -------------------------------------------------------------------------------- /Day11_Destructuring_Spreading/level1.js: -------------------------------------------------------------------------------- 1 | // Level1 Challenges: Basic destructuring 2 | const constants = [2.72, 3.14, 9.81, 37,100]; 3 | const countries = ['Finland', 'Estonia', 'Sweden', 'Denmark', 'Norway']; 4 | 5 | const rectangle = { 6 | width: 20, 7 | height: 10, 8 | area: 200, 9 | perimeter: 60 10 | } 11 | // 1 12 | let [e, pi, gravity, humanBoyTemp, waterBoilingTemp] = constants; 13 | 14 | // 2 15 | let [fin, est, sw, den, nor] = countries; 16 | 17 | // 3: destructuring by key 18 | let { width: w, height: h, area: a, perimeter: p }= rectangle; 19 | 20 | // LEVEL 1 Complete 21 | -------------------------------------------------------------------------------- /Day11_Destructuring_Spreading/level2.js: -------------------------------------------------------------------------------- 1 | // LEVEL 2 Challenges :Intermediate 2 | // users array 3 | const users = [ 4 | { 5 | name: 'Brook', 6 | scores: 75, 7 | skills: ['HTML', 'CSS', 'JS'], 8 | age: 16 9 | }, // 1 10 | { 11 | name: 'Alex', 12 | scores: 80, 13 | skills: ['HTML', 'CSS', 'JS'], 14 | age: 18 15 | },{ 16 | name: 'David', 17 | scores: 75, 18 | skills: ['HTML', 'CSS'], 19 | age: 22 20 | },{ 21 | name: 'John', 22 | scores: 85, 23 | skills: ['HTML'], 24 | age: 25 25 | },{ 26 | name: 'Sara', 27 | scores: 95, 28 | skills: ['HTML', 'CSS', 'JS'], 29 | age: 26 30 | },{ 31 | name: 'Martha', 32 | scores: 80, 33 | skills: ['HTML', 'CSS', 'JS'], 34 | age: 18 35 | },{ 36 | name: 'Thomas', 37 | scores: 90, 38 | skills: ['HTML', 'CSS', 'JS'], 39 | age: 20 40 | } 41 | ] 42 | 43 | // 1 44 | for(const {name, scores, skills, age} of users) { 45 | console.log(name, scores, age); 46 | skills.forEach(x => console.log(x)); 47 | } 48 | 49 | // 2: Find persons having <2 skills 50 | for (const { name, scores, skills, age } of users) { 51 | if(skills.length < 2) { 52 | console.log(name); // John 53 | } 54 | } 55 | 56 | // LEVEL 2 Complete 57 | -------------------------------------------------------------------------------- /Day11_Destructuring_Spreading/level3.js: -------------------------------------------------------------------------------- 1 | // 1 : countries is present in countries.js file 2 | for(const {name, capital, languages, population} of countries) { 3 | console.log('Name', name); 4 | console.log('Capital', capital); 5 | console.log('languages', languages); 6 | console.log('population', population); 7 | } 8 | 9 | // 2 10 | const student = ['David', ['HTML', 'CSS', 'JS', 'React'], [98, 85, 90, 95]] 11 | 12 | let [name, skills, [,, jsScore, reactScore]] = student; 13 | console.log(name, skills, jsScore, reactScore) 14 | 15 | // 3 16 | const students = [ 17 | [ 'David', ['HTM' ,'CSS','JS','React'] , [ 98 , 85 , 90 , 95 ] ] , 18 | [ 'John' , ['HTM', 'CSS','JS', 'React' ] , [ 85 , 80 , 85 , 80 ] ] 19 | ]; 20 | 21 | const convertArrayToObject = (arr) => { 22 | let arrOfObjects = []; 23 | for(const [name, skills, scores] of arr) 24 | arrOfObjects.push({name, skills, scores}); 25 | return arrOfObjects; 26 | } 27 | convertArrayToObject(students); 28 | 29 | // 4 30 | const s = { 31 | name: 'David', 32 | age: 25, 33 | skills: { 34 | frontEnd: [ 35 | { skill: 'HTML', level: 10 }, 36 | { skill: 'CSS', level: 8 }, 37 | { skill: 'JS', level: 8 }, 38 | { skill: 'React', level: 9 } 39 | ], 40 | backEnd: [ 41 | { skill: 'Node',level: 7 }, 42 | { skill: 'GraphQL', level: 8 }, 43 | ], 44 | dataBase:[ 45 | { skill: 'MongoDB', level: 7.5 }, 46 | ], 47 | dataScience:['Python', 'R', 'D3.js'] 48 | } 49 | } 50 | 51 | let skillz = { 52 | bts: {skill: 'Bootstrap', level: 8}, 53 | exp: {skill: 'Express', level: 9}, 54 | sql: {skill: 'SQL', level: 8}, 55 | ds : 'SQL' 56 | } 57 | 58 | let copiedStudent = {...s}; 59 | for(let i=0; i parseFloat(x)).reduce((sum, x) => sum + x, 0); 7 | console.log(income) 8 | // 2 9 | points = ['201', '2', '-4', '-3', '-10', '0', '4', '8'] 10 | let numPattern = new RegExp(/\-?[0-9]+/,'g'); 11 | let extractedPoints = points.map(x => parseFloat(x.match(numPattern)[0])).sort((a,b) => a - b); 12 | 13 | let distance = Math.abs(extractedPoints[0] - extractedPoints[extractedPoints.length - 1]); 14 | 15 | // 3 identify if string is valid js variable 16 | // ignoring the possiblity of input being reserved keyword 17 | let is_valid_variable = (varName) => { 18 | let validVar = /^[$|_|a-z|A-Z][1-9|a-z|A-Z|_]*?/ 19 | return Boolean(varName.match(validVar)); 20 | } 21 | console.log(is_valid_variable('234helloJS')); 22 | // LEVEL 1 complete 23 | -------------------------------------------------------------------------------- /Day12_RegularExpressions/level2.js: -------------------------------------------------------------------------------- 1 | // LEVEL 2 Challenges: RegEx 2 | // 1 3 | paragraph = `I love teaching. If you do not love teaching what else can you love. I love Python if you do not love something which can give you all the capabilities to develop an application what else can you love.` 4 | let tenMostFrequentWords = (text, range=10) => { 5 | let pattern = /[a-z|A-Z]*/g; 6 | return Object.entries(text.match(pattern).reduce((dict, word) => { 7 | dict[word] = (dict[word] || 0) +1; 8 | return dict; 9 | }, {})).sort((a, b) => b[1]-a[1]).slice(0, range); 10 | } 11 | tenMostFrequentWords(paragraph).forEach(x => console.log(x)); 12 | 13 | //another method 14 | words=[] 15 | total=[] 16 | 17 | function tenMostFrequentWords(paragraph){ 18 | var replaced=paragraph.replace(/\./g,''); 19 | var arrOfPara = replaced.toString().split(' '); 20 | 21 | for(let i=0;i { 5 | let pattern = /[~|@|#|!|$|%|\^|&|;|\\?]/g; 6 | let cleanedText = text.replace(pattern, '') 7 | return tenMostFrequentWords(cleanedText); 8 | } 9 | console.log(cleanText(sentence)); 10 | 11 | // level 3 JS 12 | -------------------------------------------------------------------------------- /Day13_Console_Object/level1.js: -------------------------------------------------------------------------------- 1 | // LEVEL 1 Challenges 2 | let countries = ['Pakistan', 'India', 'Afghanistan', 'Turkey']; 3 | 4 | let countriesObj = {first: 'Pakistan', Second: 'India', Third: 'Afghanistan', Fourth: 'Turkey'}; 5 | 6 | // 1 7 | console.table(countries); 8 | 9 | // 2 10 | console.table(countriesObj); 11 | 12 | // 3 13 | console.group('Array and Object'); 14 | console.table(countries); 15 | console.table(countriesObj); 16 | console.groupEnd(); 17 | 18 | // End of level 1 19 | -------------------------------------------------------------------------------- /Day13_Console_Object/level2.js: -------------------------------------------------------------------------------- 1 | // LEVEL 2 2 | // 1 3 | console.assert(10 > 2 * 10, '10 is not greater than 20'); 4 | 5 | // 2 6 | console.warn('%cDeprecation Warning!', 'color: red') 7 | 8 | // 3 9 | console.error('Warning was ignored, so error occured! :\)'); 10 | 11 | // level 1 complete 12 | -------------------------------------------------------------------------------- /Day13_Console_Object/level3.js: -------------------------------------------------------------------------------- 1 | // LEVEL 3 Challenges: Console object 2 | // 1 compare the for of, for, while and forEach loop for specific task using console.time 3 | 4 | let array = [1,2,3,4,5,6,7,8,9,0]; 5 | 6 | // i: regualr for loop 7 | console.time('For Loop'); 8 | for(let i = 0; i < array.length; i++) { 9 | console.log(array[i]); 10 | } 11 | console.timeEnd('For Loop') 12 | // ii: For of loop 13 | console.time('for-of loop'); 14 | for(const value of array) { 15 | console.log(value); 16 | } 17 | console.timeEnd('for-of loop') 18 | 19 | // iii. while loop 20 | console.time(`While Loop`) 21 | let i = 0; 22 | while(i < array.length) { 23 | console.log(array[i]); 24 | i++; 25 | } 26 | console.timeEnd('While Loop') 27 | 28 | // iv: For each loop 29 | console.time('ForEach Loop') 30 | array.forEach(x => console.log(x)); 31 | console.timeEnd(`ForEach Loop`); 32 | 33 | // The most efficient here is forEach loop and least efficient is for of loop. but stll unpredictable. 34 | -------------------------------------------------------------------------------- /Day14_Error_Handling/level1.js: -------------------------------------------------------------------------------- 1 | // LEVEL 1 Challenge 2 | // 1 3 | function toUppercase(string) { 4 | if (typeof string !== "string") { 5 | throw TypeError("Wrong type given, expected a string"); 6 | } 7 | return string.toUpperCase(); 8 | } 9 | 10 | console.log(toUpperCase(1); // non-string 11 | 12 | -------------------------------------------------------------------------------- /Day14_Error_Handling/level2.js: -------------------------------------------------------------------------------- 1 | // LEVEL 2 Challenge 2 | let divideWholeArray = (arr, divisor) => { 3 | let resultant = arr.map(x => { 4 | let result; 5 | try { 6 | result = x / divisor; 7 | } 8 | catch(error){ 9 | result = undefined; 10 | } 11 | finally { 12 | return result; 13 | } 14 | }) 15 | } 16 | 17 | let arr = [1, 2, 3, ,4 ,5]; 18 | let undefinedArray = divideWholeArray(arr, 0); 19 | -------------------------------------------------------------------------------- /Day14_Error_Handling/level3.js: -------------------------------------------------------------------------------- 1 | // LEVEL 3 Challenge 2 | let ZeroDivisionError = new Error('Division By Zero is not allowed!'); 3 | let safeDivide = (a, b) => { 4 | try { 5 | if(b === 0) throw ZeroDivisionError; 6 | return a/b; 7 | } 8 | catch (error) { 9 | return error.message; 10 | } 11 | } 12 | let result = safeDivide(a/b); 13 | -------------------------------------------------------------------------------- /Day15_Classes/level3.js: -------------------------------------------------------------------------------- 1 | // LEVEL 3 Challenge 2 | // 1 create a statistics class 3 | class statistics { 4 | constructor(arr) { 5 | this.arr = arr; 6 | } 7 | 8 | // methods 9 | count() { return this.arr.length; } 10 | 11 | sum() { return this.arr.reduce((sum, value) => sum + value, 0)}; 12 | 13 | min() { return this.arr.reduce((min, val) => { 14 | min = min < val ? min: val; 15 | return min; 16 | })} 17 | 18 | max() { return this.arr.reduce((max, val) => {max = max < val? val: max})}; 19 | 20 | range() {return Math.abs(this.max() - this.min())}; 21 | 22 | mean() { 23 | return arr.reduce((a, b) => (a+b)/arr.length, 0) 24 | } 25 | 26 | median() { 27 | let sorted = this.arr.sort((a, b) => a-b); 28 | let len = sorted.length; 29 | if(len%2===0) { 30 | return (sorted[parseInt(len/2)] +sorted[parseInt(len/2)-1]); 31 | } 32 | else return (sorted[parseInt(len/2)]); 33 | } 34 | 35 | mode() { 36 | return Object.entries(this.arr.reduce((obj, cur) => { 37 | obj[cur] = (obj[cur] || 0) +1; 38 | return obj; 39 | }, {})).sort((a, b) => a[1] - b[1]).pop(); 40 | } 41 | 42 | var() { 43 | return this.arr.reduce((v, cur) => 44 | v + Math.pow(cur, 2), 0) 45 | } 46 | 47 | std() { 48 | return Math.sqrt(this.var()); 49 | } 50 | } 51 | let arr = [1, 2,3 ,4, 432, 2, 3, 3, 3]; 52 | let stats = new statistics(arr); 53 | console.log(stats.std()) 54 | 55 | // 2 create a bank account 56 | class PersonAccount { 57 | constructor(fName, lName) { 58 | this.fName = fName; 59 | this.lName = lName; 60 | 61 | // inits 62 | this.accountBalance = 0; 63 | this.incomes = []; 64 | this.expenses = []; 65 | } 66 | 67 | // methods 68 | totalIncome() { return this.incomes.reduce((sum, cur) => sum + cur, 0)}; 69 | 70 | totalExpense() { return this.expenses.reduce((sum, cur) => sum + cur, 0)}; 71 | 72 | checkAccountBalance() { 73 | return this.accountBalance; 74 | } 75 | withDraw(bal) { 76 | if (bal > 0 && this.accountBalance > 0) { 77 | this.accountBalance -= bal; 78 | } 79 | } 80 | accountInfo() { 81 | return ` 82 | *****Billing Account Info****** 83 | Name: ${this.fName + ' ' + this.lName} 84 | Baln: ${this.accountBalance}$ 85 | Incm: ${this.totalIncome()}$ 86 | Expn: ${this.totalExpense()}$ 87 | 88 | _________END OF INFO__________ 89 | ` 90 | } 91 | // setters 92 | set addIncome(income) { 93 | if(income > 0) { 94 | this.incomes.push(income); 95 | } 96 | } 97 | 98 | set addExpense(expense) { 99 | if(expense > 0) { 100 | this.expenses.push(expense); 101 | } 102 | } 103 | 104 | set deposit(bal) { 105 | if (bal > 0) this.accountBalance += bal; 106 | } 107 | } 108 | 109 | // create an object 110 | let bilAccount = new PersonAccount('Hamza', "Mateen"); 111 | 112 | console.log(bilAccount.accountInfo()) 113 | 114 | // END OF LEVEL 3 Challenge! 115 | -------------------------------------------------------------------------------- /Day15_Classes/level_1_and_2.js: -------------------------------------------------------------------------------- 1 | // LEVEL 1 Challenge: basics of OOP 2 | // 1 3 | class Animal { 4 | constructor(name, age, color, legs) { 5 | this.name = name; 6 | this.age = age; 7 | this.color = color; 8 | this.legs = legs; 9 | } 10 | 11 | get getInfo() { 12 | return `${this.name} is ${this.age} years old, it has ${this.legs} legs. it is ${this.color}`; 13 | } 14 | 15 | set setName(name) { 16 | this.name = name; 17 | } 18 | 19 | set setColor(color) { 20 | this.color = color; 21 | } 22 | 23 | set setAge (age) { 24 | this.age = age; 25 | } 26 | 27 | get getName() { 28 | return this.name; 29 | } 30 | } 31 | // create animal here 32 | let animal = new Animal('venom', 23, 'black', 4); 33 | 34 | console.log(animal.getInfo); 35 | animal.setName = 'Carnage'; 36 | animal.setColor = 'Red'; 37 | animal.setAge = 324; 38 | 39 | console.log(animal.getInfo); 40 | 41 | // 2 create derived classes out of animal 42 | // i 43 | class Cat extends Animal { 44 | constructor(name, age, color, legs, eyeColor){ super(name, age, color, legs); 45 | this.eyeColor = eyeColor; 46 | } 47 | 48 | // level 2: overridden the getInfo getter 49 | get getInfo () { 50 | return super.getInfo + `Its Eye Color is ${this.color}`; 51 | } 52 | // add another method to extend the class 53 | meow() { 54 | return 'meow meow \'\(`-`\)\''; 55 | } 56 | } 57 | 58 | let toity = new Cat('toity', 2, 'white', 4, 'hazel'); 59 | 60 | // ii 61 | class Dog extends Animal { 62 | constructor(name, age, color, legs, breed){ super(name, age, color, legs); 63 | this.breed = breed; 64 | } 65 | 66 | // level 2: override a method 67 | get getInfo() { 68 | return super.getInfo + `. ${super.getName} belongs to ${this.breed} breed!`; 69 | } 70 | 71 | // add an additional method 72 | woof() { 73 | return 'woof woof!'; 74 | } 75 | } 76 | 77 | let sherman = new Dog('Sherman', 5, 'brown', 4, 'German Shepard'); 78 | console.log(sherman.getInfo) 79 | console.log(sherman.woof()); 80 | console.log(toity.meow()); 81 | 82 | // LEVEL 1 and 2 completed => created base and dervied classs, added extra functionality to those, and overrid a function also. 83 | -------------------------------------------------------------------------------- /Day16_JSON/level1.js: -------------------------------------------------------------------------------- 1 | // LEVEL 1 Challenges 2 | // 1 3 | let skillsString = JSON.stringify(skills); 4 | 5 | // 2 6 | let ageString = JSON.stringify(age); 7 | 8 | // 3 9 | let isMarriedString = JSON.stringify(isMarried) 10 | 11 | // 4 12 | let studentObjString = JSON.stringify(student); 13 | 14 | // LEVEL 1 Complete 15 | -------------------------------------------------------------------------------- /Day16_JSON/level_2_and_3.js: -------------------------------------------------------------------------------- 1 | // LEVEL 2 Challenge 2 | // 1 3 | let fewStudents = JSON.stringify(student, ['firstName', 'lastName', 'skills'], 4); 4 | 5 | // LEVEL 3 Challenge 6 | // 1 7 | let jsonedText = JSON.parse(txt); 8 | 9 | // 2 10 | let filteredJSON = JSON.parse(txt, (key, value) => { 11 | let max = 0; 12 | max = max < value.length ? value.length: max; 13 | 14 | return max > value.length ? undefined: value; 15 | }) 16 | 17 | console.log(filteredJSON); 18 | // Level 3 complete 19 | -------------------------------------------------------------------------------- /Day17_Web_Storages/level_1_2_3.js: -------------------------------------------------------------------------------- 1 | // LEVEL 1 Challenges 2 | localStorage.setItem('firstName', 'Hamza'); 3 | localStorage.setItem('lastName', 'Mateen'); 4 | localStorage.setItem('age', '123'); 5 | localStorage.setItem('country', 'Pakistan'); 6 | localStorage.setItem('city', 'dikhan'); 7 | 8 | console.log(localStorage.getItem('firstName')) 9 | 10 | // clear the storage 11 | localStorage.clear(); 12 | 13 | // LEVEL 2 Challenge 14 | let student = { 15 | firstName: 'John', 16 | lastName : 'Nash', 17 | age : 23, 18 | country : 'US', 19 | enrolled : false, 20 | } 21 | // store in the storage 22 | let stdText = JSON.stringify(student); 23 | localStorage.setItem('student', stdText); 24 | 25 | // LEVEL 3 Challenge 26 | console.log(JSON.parse(localStorage.getItem('student'))); 27 | 28 | // LEVELs Complete 29 | -------------------------------------------------------------------------------- /Day19_Closures/level_1_2_3.js: -------------------------------------------------------------------------------- 1 | // LEVEL 1: Closures 2 | let first = (num1) => { 3 | let second = (num2) => { 4 | return num1 * num2; 5 | } 6 | return second; 7 | } 8 | let partialResult = first(2); 9 | let fullResult = partialResult(3); 10 | console.log(fullResult); 11 | 12 | // LEVEL 2 13 | let everythingTWO = (number) => { 14 | let addTWO = () => { 15 | return number += 2; 16 | } 17 | 18 | let subTWO = () => { 19 | return number -= 2; 20 | } 21 | 22 | let mulTWO = () => { 23 | return number *= 2; 24 | } 25 | 26 | return { 27 | add: addTWO(), 28 | sub: subTWO(), 29 | mul: mulTWO(), 30 | 31 | } 32 | } 33 | 34 | let number = 2; 35 | let op = everythingTWO(number); 36 | 37 | console.log(op.add); // 4 38 | console.log(op.sub); // 2 39 | console.log(op.mul); // 4 40 | 41 | // LEVEL 3 is a challenge from previous section. 42 | -------------------------------------------------------------------------------- /Day20_Writing_Clean_Code/README20.md: -------------------------------------------------------------------------------- 1 | *_Note: there were no challenges for this day!_* 2 | -------------------------------------------------------------------------------- /Day21_DOM/indexDOM.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 30DaysOfJavaScript:21 Day 6 | 7 | 8 | 9 |
10 |

Asabeneh Yetayeh challenges in 2020

11 |

30DaysOfJavaScript Challenge

12 |

13 |
    14 |
  • 30DaysOfPython Challenge Done
  • 15 |
  • 30DaysOfJavaScript Challenge Ongoing
  • 16 |
  • 30DaysOfReact Challenge Coming
  • 17 |
  • 30DaysOfFullStack Challenge Coming
  • 18 |
  • 30DaysOfDataAnalysis Challenge Coming
  • 19 |
  • 30DaysOfReactNative Challenge Coming
  • 20 |
  • 30DaysOfMachineLearning Challenge Coming
  • 21 |
22 |
23 | 24 | 25 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Day21_DOM/level1.js: -------------------------------------------------------------------------------- 1 | // LEVEL 1 2 | // 1 3 | let firstParagraph = document.querySelector('p'); 4 | 5 | // 2 6 | let firstP = document.querySelector("#first"); 7 | let secondP = document.querySelector('#second'); 8 | let thirdP = document.querySelector('#third'); 9 | let fourthP = document.querySelector('#fourth'); 10 | 11 | // 3 12 | let allParagraphs = document.querySelectorAll('p'); 13 | 14 | // 4 15 | allParagraphs.forEach(x => console.log(x.textContent)); 16 | 17 | // 5 18 | fourthP.textContent = 'Fourth Paragraph'; 19 | console.log(fourthP.textContent); 20 | 21 | // 6 set ID and CLASS 22 | // method 1 23 | allParagraphs.forEach(x => x.classList.add('paragraph')); 24 | 25 | // method 2 26 | firstP.setAttribute('class', 'first-paragraph'); 27 | secondP.setAttribute('class', 'second-paragraph'); 28 | 29 | // method 3 30 | thirdP.className = 'third-paragraph'; 31 | fourthP.className = 'fourth-paragraph'; 32 | -------------------------------------------------------------------------------- /Day21_DOM/level2.js: -------------------------------------------------------------------------------- 1 | // LEVEL 2 2 | // 1 3 | allParagraphs.forEach(x => { 4 | x.style.color = 'red'; 5 | x.style.backgroundColor = 'black'; 6 | x.style.fontSize = '15px'; 7 | x.style.fontFamily = 'Helvetica'; 8 | }); 9 | 10 | // 2 11 | let index = 1; 12 | for (let each of allParagraphs) { 13 | each.style.color = 'white'; 14 | if (index % 2 === 0) 15 | each.style.backgroundColor = 'green'; 16 | else each.style.backgroundColor = 'red'; 17 | 18 | index++; 19 | } 20 | 21 | // 3 22 | let a = 1; 23 | for (let each of allParagraphs) { 24 | if (a == 1) { 25 | each.textContent = `${a}st Pargraph!`; 26 | } else if (a === 2) { 27 | each.textContent = `${a}nd Paragraph`; 28 | } else if (a == 3) { 29 | each.textContent = `${a}rd Pargraphs`; 30 | } else 31 | each.textContent = `${a}th Paragraph!`; 32 | 33 | each.setAttribute('id', `${a}-paragraph`); 34 | each.setAttribute('class', 'Paragraph'); 35 | a++; 36 | } 37 | -------------------------------------------------------------------------------- /Day21_DOM/level3_DOM.js: -------------------------------------------------------------------------------- 1 | // Level 3: Mini DOM Project 1 2 | let yearText = document.querySelector('strong'); 3 | yearText.style.fontSize = '40px'; 4 | 5 | // generate color in hexadec form 6 | let generateColor = () => { 7 | let alphanums = '0123456789abcdef'; 8 | 9 | let colorArr = []; 10 | for(let i=0; i<6; i++) { 11 | let index = Math.floor(Math.random() * 15); 12 | colorArr.push(alphanums[index]); 13 | } 14 | return '#' + colorArr.join(''); 15 | } 16 | 17 | // adding color to 2020 18 | setInterval(() => { 19 | yearText.style.color = generateColor(); 20 | }, 1000) 21 | 22 | let h1 = document.querySelector('h1'); 23 | h1.style.fontSize = '15px'; 24 | h1.style.fontFamily = 'courier'; 25 | h1.style.fontWeight = 'bold'; 26 | h1.style.textAlign = 'center'; 27 | 28 | let h2 = document.querySelector('h2'); 29 | h2.style.color = 'grey'; 30 | h2.style.fontSize = '12px'; 31 | h2.style.textAlign = 'center'; 32 | h2.style.fontWeight = '500'; 33 | h2.style.textDecoration = 'underline'; 34 | h2.style.marginBottom = '10px' 35 | h2.style.fontFamily = 'san-serif'; 36 | 37 | // add date to the DOM 38 | // let p = document.createElement('p'); 39 | let getDate = () => { 40 | let d = new Date(); 41 | 42 | let months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; 43 | 44 | let monthIndex = d.getMonth(); 45 | let year = d.getFullYear(); 46 | let date = d.getDate(); 47 | let hour = d.getHours(); 48 | let mins = d.getMinutes(); 49 | 50 | date = date < 10? '0'+date.toString(): date; 51 | hour = hour < 10? '0'+hour.toString(): hour; 52 | mins = mins < 10? '0'+mins.toString():mins; 53 | 54 | return `${months[monthIndex]} ${date}, ${year} ${hour}:${mins}`; 55 | } 56 | 57 | 58 | let date = document.querySelector('p'); 59 | date.textContent = getDate(); 60 | 61 | date.style.margin = 'auto'; 62 | date.style.padding = '6px' 63 | date.style.textAlign = 'center'; 64 | date.style.fontSize = '12px'; 65 | date.style.fontWeight = '400'; 66 | date.style.width = '40%'; 67 | 68 | setInterval(() => { 69 | date.style.backgroundColor = generateColor(); 70 | }, 1000); 71 | let listItems = document.querySelectorAll('li'); 72 | 73 | for(let item of listItems) { 74 | item.style.listStyleType = 'none'; 75 | item.style.fontWeight = '350'; 76 | item.style.padding = '8px'; 77 | item.style.margin = '6px'; 78 | item.style.textAlign = 'left'; 79 | } 80 | 81 | // last task 82 | for(const item of listItems) { 83 | if(item.textContent.endsWith('Done')) 84 | item.style.backgroundColor = '#228b22'; 85 | else if (item.textContent.endsWith('Ongoing')) 86 | item.style.backgroundColor = '#FFFF00'; 87 | else item.style.backgroundColor = '#DC143C'; 88 | 89 | item.style.fontFamily = 'san-serif'; 90 | item.style.marginRight = '50px'; 91 | 92 | } 93 | -------------------------------------------------------------------------------- /Day21_DOM/level_1_2_index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 30DaysOfJavaScript:21 Day 6 | 7 | 8 | 9 |

First paragraph text!

10 |

second paragraph text!

11 |

Third paragraph text!

12 |

Fourth paragraph text!

13 | 14 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Day22_Manipulating_DOM/Project_1/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 30DaysOfJavaScript:22 Day: Number Generator 6 | 7 | 8 | 9 |

Number Generator

10 |

30DaysOfJavaScript:DOM Day 2

11 |

Author: Asabeneh Yetayeh

12 |
13 | 14 |
15 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Day22_Manipulating_DOM/Project_1/main.js: -------------------------------------------------------------------------------- 1 | let h1 = document.querySelector('h1'); 2 | let h2 = document.querySelector('h2'); 3 | let h3 = document.querySelector('h3'); 4 | 5 | h1.className = 'header'; 6 | h2.className = 'header'; 7 | h3.className = 'header'; 8 | 9 | // helper function 10 | let isPrime = num => { 11 | if (num == 1 || num == 0) return false; 12 | if (num == 2 || num == 3) 13 | return true; 14 | 15 | for (let i = 2; i <= Math.sqrt(num); i++) { 16 | if (num % i == 0) return false; 17 | } 18 | return true; 19 | } 20 | // headers styling 21 | let stdFontWeight = 400; 22 | document.querySelectorAll('.header').forEach(x => { 23 | x.style.textAlign = 'center'; 24 | x.style.fontWeight = `${stdFontWeight}`; 25 | x.style.fontFamily = 'san-serif, helvetica'; 26 | x.style.padding = '2px'; 27 | x.style.margin = '0px'; 28 | 29 | stdFontWeight -= 30; 30 | }); 31 | h2.style.textDecoration = 'underline'; 32 | 33 | // create a div container and a table within 34 | let container = document.createElement('div'); 35 | 36 | let table = document.createElement('table'); 37 | 38 | let nums = 0; 39 | while (nums <= 101) { 40 | // create table row 41 | let row = document.createElement('tr'); 42 | 43 | for (let x = 1; x <= 6; x++) { 44 | // create table data 45 | let data = document.createElement('td'); 46 | data.textContent = nums; 47 | 48 | // style the data element 49 | data.style.margin = '2px'; 50 | data.style.padding = '5px'; 51 | 52 | // selective styling 53 | if (isPrime(nums)) { 54 | data.style.backgroundColor = '#f76262'; 55 | } else if (nums % 2 !== 0) { 56 | data.style.backgroundColor = '#fee904'; 57 | } else data.style.backgroundColor = '#42b845'; 58 | 59 | // end styling 60 | row.appendChild(data); 61 | nums++; 62 | } 63 | // add row to the table 64 | table.appendChild(row); 65 | } 66 | 67 | // table styling 68 | table.style.width = '60%'; 69 | table.style.marginRight = '20%'; 70 | table.style.marginLeft = '20%'; 71 | table.style.marginTop = '1pc'; 72 | table.style.textAlign = 'center'; 73 | table.style.fontFamily = 'ariel'; 74 | table.style.fontSize = '15px'; 75 | table.style.fontWeight = 'bold'; 76 | table.style.color = 'white'; 77 | 78 | container.appendChild(table); 79 | document.body.appendChild(container); 80 | -------------------------------------------------------------------------------- /Day22_Manipulating_DOM/Project_2/countries.js: -------------------------------------------------------------------------------- 1 | const countries = [ 2 | 'Afghanistan', 3 | 'Albania', 4 | 'Algeria', 5 | 'Andorra', 6 | 'Angola', 7 | 'Antigua and Barbuda', 8 | 'Argentina', 9 | 'Armenia', 10 | 'Australia', 11 | 'Austria', 12 | 'Azerbaijan', 13 | 'Bahamas', 14 | 'Bahrain', 15 | 'Bangladesh', 16 | 'Barbados', 17 | 'Belarus', 18 | 'Belgium', 19 | 'Belize', 20 | 'Benin', 21 | 'Bhutan', 22 | 'Bolivia', 23 | 'Bosnia and Herzegovina', 24 | 'Botswana', 25 | 'Brazil', 26 | 'Brunei', 27 | 'Bulgaria', 28 | 'Burkina Faso', 29 | 'Burundi', 30 | 'Cambodia', 31 | 'Cameroon', 32 | 'Canada', 33 | 'Cape Verde', 34 | 'Central African Republic', 35 | 'Chad', 36 | 'Chile', 37 | 'China', 38 | 'Colombi', 39 | 'Comoros', 40 | 'Congo (Brazzaville)', 41 | 'Congo', 42 | 'Costa Rica', 43 | "Cote d'Ivoire", 44 | 'Croatia', 45 | 'Cuba', 46 | 'Cyprus', 47 | 'Czech Republic', 48 | 'Denmark', 49 | 'Djibouti', 50 | 'Dominica', 51 | 'Dominican Republic', 52 | 'East Timor (Timor Timur)', 53 | 'Ecuador', 54 | 'Egypt', 55 | 'El Salvador', 56 | 'Equatorial Guinea', 57 | 'Eritrea', 58 | 'Estonia', 59 | 'Ethiopia', 60 | 'Fiji', 61 | 'Finland', 62 | 'France', 63 | 'Gabon', 64 | 'Gambia, The', 65 | 'Georgia', 66 | 'Germany', 67 | 'Ghana', 68 | 'Greece', 69 | 'Grenada', 70 | 'Guatemala', 71 | 'Guinea', 72 | 'Guinea-Bissau', 73 | 'Guyana', 74 | 'Haiti', 75 | 'Honduras', 76 | 'Hungary', 77 | 'Iceland', 78 | 'India', 79 | 'Indonesia', 80 | 'Iran', 81 | 'Iraq', 82 | 'Ireland', 83 | 'Israel', 84 | 'Italy', 85 | 'Jamaica', 86 | 'Japan', 87 | 'Jordan', 88 | 'Kazakhstan', 89 | 'Kenya', 90 | 'Kiribati', 91 | 'Korea, North', 92 | 'Korea, South', 93 | 'Kuwait', 94 | 'Kyrgyzstan', 95 | 'Laos', 96 | 'Latvia', 97 | 'Lebanon', 98 | 'Lesotho', 99 | 'Liberia', 100 | 'Libya', 101 | 'Liechtenstein', 102 | 'Lithuania', 103 | 'Luxembourg', 104 | 'Macedonia', 105 | 'Madagascar', 106 | 'Malawi', 107 | 'Malaysia', 108 | 'Maldives', 109 | 'Mali', 110 | 'Malta', 111 | 'Marshall Islands', 112 | 'Mauritania', 113 | 'Mauritius', 114 | 'Mexico', 115 | 'Micronesia', 116 | 'Moldova', 117 | 'Monaco', 118 | 'Mongolia', 119 | 'Morocco', 120 | 'Mozambique', 121 | 'Myanmar', 122 | 'Namibia', 123 | 'Nauru', 124 | 'Nepal', 125 | 'Netherlands', 126 | 'New Zealand', 127 | 'Nicaragua', 128 | 'Niger', 129 | 'Nigeria', 130 | 'Norway', 131 | 'Oman', 132 | 'Pakistan', 133 | 'Palau', 134 | 'Panama', 135 | 'Papua New Guinea', 136 | 'Paraguay', 137 | 'Peru', 138 | 'Philippines', 139 | 'Poland', 140 | 'Portugal', 141 | 'Qatar', 142 | 'Romania', 143 | 'Russia', 144 | 'Rwanda', 145 | 'Saint Kitts and Nevis', 146 | 'Saint Lucia', 147 | 'Saint Vincent', 148 | 'Samoa', 149 | 'San Marino', 150 | 'Sao Tome and Principe', 151 | 'Saudi Arabia', 152 | 'Senegal', 153 | 'Serbia and Montenegro', 154 | 'Seychelles', 155 | 'Sierra Leone', 156 | 'Singapore', 157 | 'Slovakia', 158 | 'Slovenia', 159 | 'Solomon Islands', 160 | 'Somalia', 161 | 'South Africa', 162 | 'Spain', 163 | 'Sri Lanka', 164 | 'Sudan', 165 | 'Suriname', 166 | 'Swaziland', 167 | 'Sweden', 168 | 'Switzerland', 169 | 'Syria', 170 | 'Taiwan', 171 | 'Tajikistan', 172 | 'Tanzania', 173 | 'Thailand', 174 | 'Togo', 175 | 'Tonga', 176 | 'Trinidad and Tobago', 177 | 'Tunisia', 178 | 'Turkey', 179 | 'Turkmenistan', 180 | 'Tuvalu', 181 | 'Uganda', 182 | 'Ukraine', 183 | 'United Arab Emirates', 184 | 'United Kingdom', 185 | 'United States', 186 | 'Uruguay', 187 | 'Uzbekistan', 188 | 'Vanuatu', 189 | 'Vatican City', 190 | 'Venezuela', 191 | 'Vietnam', 192 | 'Yemen', 193 | 'Zambia', 194 | 'Zimbabwe' 195 | ] 196 | -------------------------------------------------------------------------------- /Day22_Manipulating_DOM/Project_2/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 30DaysOfJavaScript:22 Day: World Countries List 6 | 7 | 8 | 9 |
10 |

World Countries List

11 | 12 |

13 |

30DaysOfJavaScript:DOM-Day-2

14 |

Author: Asabeneh Yetayeh

15 | 16 |
17 | 18 |
19 |
20 | 21 |
22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Day22_Manipulating_DOM/Project_2/script.js: -------------------------------------------------------------------------------- 1 | document.body.style.fontFamily = 'san-serif, helvetica'; 2 | 3 | let h2 = document.querySelector('h2'); 4 | h2.textContent = h2.textContent.toUpperCase(); 5 | h2.style.letterSpacing = '8px'; 6 | h2.style.textAlign = 'center'; 7 | h2.style.fontWeight = '600'; 8 | h2.style.margin = '0px'; 9 | h2.style.padding = '2px'; 10 | let totalCountries = document.querySelector('#total-countries'); 11 | totalCountries.textContent = `Total Number of countries: ${countries.length}`; 12 | totalCountries.style.textAlign = 'center'; 13 | totalCountries.style.fontWeight = '550'; 14 | totalCountries.style.margin = '0px'; 15 | totalCountries.style.padding = '2px'; 16 | 17 | let h3Headers = document.querySelectorAll('h3'); 18 | 19 | h3Headers.forEach(x => { 20 | x.style.textAlign = 'center'; 21 | x.style.padding = '2px'; 22 | x.style.margin = '0px'; 23 | }); 24 | 25 | h3Headers[0].style.fontSize = '13px'; 26 | h3Headers[0].style.textDecoration = 'underline'; 27 | h3Headers[0].style.fontWeight = '380'; 28 | 29 | h3Headers[1].style.fontSize = '11px'; 30 | h3Headers[1].style.fontWeight = '360'; 31 | 32 | // table system yet again 33 | let table = document.createElement('table'); 34 | 35 | // styling 36 | table.style.textAlign = 'center'; 37 | table.style.padding = '2px'; 38 | table.style.width = '50%'; 39 | table.style.marginLeft = '25%' 40 | table.style.marginRight = '25%' 41 | table.style.fontSize = '7px'; 42 | table.style.fontWeight = '400'; 43 | table.style.letterSpacing = '1px'; 44 | 45 | // text addition 46 | let countryCount = 0; 47 | while(countryCount < countries.length){ 48 | let row = document.createElement('tr'); 49 | 50 | for(let i=0; i<6; i++) { 51 | if(countryCount == countries.length) break; 52 | let data = document.createElement('td'); 53 | data.textContent = countries[countryCount].toUpperCase(); 54 | 55 | data.style.paddingTop = '30px'; 56 | data.style.paddingBottom = '30px'; 57 | data.style.margin = '2px'; 58 | data.style.border = '1px #eeeef3 solid'; 59 | 60 | row.appendChild(data); 61 | countryCount++; 62 | } 63 | table.appendChild(row); 64 | } 65 | 66 | document.body.appendChild(table); 67 | -------------------------------------------------------------------------------- /Day22_Manipulating_DOM/Project_3/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 30DaysOfJavaScript:22 Day: Challenge Info 6 | 7 | 8 | 9 |
10 |
11 | 12 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Day22_Manipulating_DOM/Project_3/main.js: -------------------------------------------------------------------------------- 1 | // requirements 2 | document.body.style.fontFamily = 'san-serif, helvetica'; 3 | let wrapper = document.querySelector('.wrapper'); 4 | 5 | let getDate = () => { 6 | let d = new Date(); 7 | 8 | let months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; 9 | 10 | let monthIndex = d.getMonth(); 11 | let year = d.getFullYear(); 12 | let date = d.getDate(); 13 | let hour = d.getHours(); 14 | let mins = d.getMinutes(); 15 | 16 | date = date < 10? '0'+date.toString(): date; 17 | hour = hour < 10? '0'+hour.toString(): hour; 18 | mins = mins < 10? '0'+mins.toString():mins; 19 | 20 | return `${months[monthIndex]} ${date}, ${year} ${hour}:${mins}`; 21 | } 22 | 23 | let generateColor = () => { 24 | let alphanums = '0123456789abcdef'; 25 | 26 | let colorArr = []; 27 | for(let i=0; i<6; i++) { 28 | let index = Math.floor(Math.random() * 15); 29 | colorArr.push(alphanums[index]); 30 | } 31 | return '#' + colorArr.join(''); 32 | } 33 | // end requirements 34 | 35 | // headings 36 | let h1 = document.createElement('h1'); 37 | h1.innerHTML = 'Asabeneh Yetayeh Challenges in 2020'; 38 | h1.style.textAlign = 'center'; 39 | h1.style.fontSize = '20px'; 40 | h1.style.fontWeight = '400'; 41 | h1.style.marginBottom = '5px'; 42 | h1.style.padding = '5px'; 43 | wrapper.appendChild(h1); 44 | 45 | let yearText = document.querySelector('strong'); 46 | yearText.style.fontSize = '40px'; 47 | 48 | setInterval(() => yearText.style.color = generateColor(), 1000); 49 | 50 | let h3 = document.createElement('h3'); 51 | h3.textContent = '30DaysOfJavaScript Challenge'; 52 | h3.style.fontWeight = '370'; 53 | h3.style.fontSize = '15px'; 54 | h3.style.textDecoration = 'underline'; 55 | h3.style.textAlign = 'center'; 56 | h3.style.padding = '3px'; 57 | h3.style.margin = '0px'; 58 | 59 | wrapper.appendChild(h3); 60 | 61 | // date headings 62 | let date = document.createElement('h4'); 63 | date.textContent = getDate(); 64 | date.style.fontSize = '12px'; 65 | date.style.padding = '6px'; 66 | date.style.margin = 'auto'; 67 | date.style.textAlign = 'center'; 68 | date.style.width = '15%'; 69 | date.style.fontWeight = '400'; 70 | date.style.marginBottom = '5px'; 71 | setInterval(() => { 72 | date.style.backgroundColor = generateColor(); 73 | }, 1000); 74 | 75 | wrapper.appendChild(date); 76 | 77 | // prereuisites end 78 | let list = document.createElement('ul'); 79 | list.style.listStyleType = 'none'; 80 | list.style.width = '80%'; 81 | list.style.margin = 'auto'; 82 | 83 | // let us do it 84 | asabenehChallenges2020.challenges.forEach(x => { 85 | let item = document.createElement('li'); 86 | 87 | // innerHTML live :) 88 | // 1 89 | let titleSpan = document.createElement('span'); 90 | let title = document.createTextNode(x.name); 91 | titleSpan.appendChild(title); 92 | 93 | // 2 94 | let dropdown = document.createElement('details'); 95 | let dropdownSpan = document.createElement('span'); 96 | 97 | // modify detail 98 | let summary = document.createElement('summary'); 99 | summary.textContent = x.name.split(' ')[x.name.split(' ').length -1]; 100 | // add the topics 101 | let topics = document.createElement('ul'); 102 | 103 | x.topics.forEach(i => { 104 | let item = document.createElement('li'); 105 | item.textContent = i; 106 | 107 | topics.appendChild(item); 108 | 109 | // styling 110 | item.style.padding='5px'; 111 | item.style.width = '90%'; 112 | item.style.marginTop ='3px'; 113 | item.style.marginBottom = '3px'; 114 | }) 115 | // styling 116 | topics.style.listStyleType = 'none'; 117 | topics.style.width = '80%'; 118 | topics.style.margin = 'auto'; 119 | 120 | dropdownSpan.appendChild(dropdown); 121 | // 3 122 | let status = document.createTextNode(x.status); 123 | let statusSpan = document.createElement('span'); 124 | statusSpan.appendChild(status); 125 | 126 | // appends 127 | item.appendChild(titleSpan); 128 | dropdown.appendChild(summary); 129 | dropdown.appendChild(topics); 130 | item.appendChild(dropdownSpan); 131 | item.appendChild(statusSpan); 132 | list.appendChild(item); 133 | 134 | // styling 135 | item.style.border='1px blue solid'; 136 | item.style.padding='5px'; 137 | item.style.width = '90%'; 138 | item.style.marginTop ='3px'; 139 | item.style.marginBottom = '3px'; 140 | }) 141 | 142 | wrapper.appendChild(list); 143 | -------------------------------------------------------------------------------- /Day22_Manipulating_DOM/Project_3/projectInfo.js: -------------------------------------------------------------------------------- 1 | const asabenehChallenges2020 = { 2 | description: 'Asabeneh Yetayeh challenges', 3 | challengeTitle: 'Asabeneh Yetayeh challenges', 4 | challengeSubtitle: '30DaysOfJavaScript Challenge', 5 | challengeYear: 2020, 6 | keywords: [ 7 | 'HTML', 8 | 'HTML5', 9 | 'CSS', 10 | 'CSS3', 11 | 'JS', 12 | 'JavaScript', 13 | 'ES6', 14 | 'Promise', 15 | 'async await', 16 | 'Database', 17 | 'React', 18 | 'React Hooks', 19 | 'Context API', 20 | 'React Router', 21 | 'Web Storage', 22 | 'localStorage', 23 | 'sessionStorage', 24 | 'Redux', 25 | 'Node', 26 | 'MongoDB', 27 | 'SQL', 28 | 'API', 29 | 'DOM', 30 | 'data science', 31 | 'MERN', 32 | 'Python', 33 | 'Flask', 34 | 'Statistics', 35 | 'Linear Algebra', 36 | 'Numpy', 37 | 'Pandas', 38 | 'Scipy', 39 | 'Scikit-learn', 40 | 'Visualization', 41 | 'D3.js' 42 | ], 43 | author: { 44 | firstName: 'Asabeneh', 45 | lastName: 'Yetayeh', 46 | titles: [ 47 | ['🌱', 'Educator'], 48 | ['💻', 'Programmer'], 49 | ['🌐', 'Developer'], 50 | ['🔥', 'Motivator'], 51 | ['📔', 'Content Creator'] 52 | ], 53 | qualifications: [ 54 | 'MSc. Computer Science Ongoing', 55 | 'BSc. Information and Communication Eng.', 56 | 'MSc. Food Technology', 57 | 'BSc.Food Technology' 58 | ], 59 | socialLinks: [ 60 | { 61 | social: 'LinkedIn', 62 | url: 'https://www.linkedin.com/in/asabeneh/', 63 | fontawesomeIcon: '' 64 | }, 65 | { 66 | social: 'Twitter', 67 | url: 'https://twitter.com/Asabeneh', 68 | fontawesomeIcon: '' 69 | }, 70 | { 71 | social: 'Github', 72 | fontawesomeIcon: '', 73 | url: 'https://github.com/Asabeneh' 74 | }, 75 | { 76 | social: 'DEV.to', 77 | fontawesomeIcon: '', 78 | url: 'https://dev.to/asabeneh' 79 | } 80 | ], 81 | skills: [ 82 | 'Web Development', 83 | 'Data Analysis', 84 | 'Data Visualization', 85 | 'Programming', 86 | 'Databases', 87 | 'Developing API' 88 | ], 89 | bio: 90 | 'I am an educator, developer, motivator and content creator. I am a life-long learner. If you like to know more about me checkout my LinkedIn or Github profile. Thank you so much for joining in my quest of changing everyone to developer.' 91 | }, 92 | challenges: [ 93 | { 94 | name: '30 Days Of Python', 95 | topics: [ 96 | 'Python', 97 | 'Flask', 98 | 'Numpy', 99 | 'Pandas', 100 | 'Statistics', 101 | 'API', 102 | 'MongoDB' 103 | ], 104 | days: 30, 105 | status: 'Done', 106 | questions: 'Above 500', 107 | projects: 'Two', 108 | interviewQns: '', 109 | githubUrl: 'https://github.com/Asabeneh/30-Days-Of-Python' 110 | }, 111 | { 112 | name: '30 Days Of JavaScript', 113 | topics: ['JavaScript', 'ES6', 'Promise', 'async and await', 'DOM'], 114 | days: 30, 115 | status: 'Ongoing', 116 | questions: 'Above 500', 117 | projects: 'About 30', 118 | interviewQns: '', 119 | githubUrl: 'https://github.com/Asabeneh/30DaysOfJavaScript' 120 | }, 121 | { 122 | name: '30 Days Of HTML&CSS', 123 | topics: ['CSS', 'Flex', 'Grid', 'CSS Animation'], 124 | days: 30, 125 | status: 'Coming', 126 | questions: 'Above 500', 127 | projects: 'Two', 128 | interviewQns: '', 129 | githubUrl: '' 130 | }, 131 | { 132 | name: '30 Days Of React', 133 | topics: [ 134 | 'React', 135 | 'React Router', 136 | 'Redux', 137 | 'Context API', 138 | 'React Hooks', 139 | 'MERN' 140 | ], 141 | days: 30, 142 | status: 'Coming', 143 | questions: '', 144 | projects: '', 145 | interviewQns: '', 146 | githubUrl: '' 147 | }, 148 | { 149 | name: '30 Days Of ReactNative', 150 | topics: ['ReactNative', 'Redux'], 151 | days: 30, 152 | status: 'Coming', 153 | questions: '', 154 | projects: 'Two', 155 | interviewQns: '', 156 | githubUrl: '' 157 | }, 158 | { 159 | name: '30 Days Of Fullstack', 160 | topics: ['React', 'Redux', 'MongoDB', 'Node', 'MERN'], 161 | days: 30, 162 | status: 'Coming', 163 | questions: '', 164 | projects: '', 165 | interviewQns: '', 166 | githubUrl: '' 167 | }, 168 | { 169 | name: '30 Days Of DataAnalysis', 170 | topics: ['Python', 'Numpy', 'Pandas', 'Statistics', 'Visualization'], 171 | days: 30, 172 | status: 'Coming', 173 | questions: '', 174 | projects: '', 175 | interviewQns: '', 176 | githubUrl: '' 177 | }, 178 | { 179 | name: '30 Days Of MachineLearning', 180 | topics: [ 181 | 'Python', 182 | 'Numpy', 183 | 'Pandas', 184 | 'Scikit-learn', 185 | 'Scipy', 186 | 'Linear Algebra', 187 | 'Statistics', 188 | 'Visualization' 189 | ], 190 | days: 30, 191 | status: 'Coming', 192 | questions: '', 193 | projects: '', 194 | interviewQns: '', 195 | githubUrl: '' 196 | } 197 | ] 198 | } 199 | -------------------------------------------------------------------------------- /Day22_Manipulating_DOM_level1_solution/numberDisplay.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin: 0px; 3 | padding: 0px; 4 | box-sizing: border-box; 5 | 6 | } 7 | 8 | body{ 9 | background-color: black; 10 | } 11 | 12 | .container{ 13 | border: 1px solid black; 14 | margin-left: 5%; 15 | margin-right: 5%; 16 | margin-top: 1%; 17 | font-size: 30px; 18 | height: 37rem; 19 | width: 90%; 20 | background: linear-gradient(45deg, pink, yellow); 21 | display: grid; 22 | grid-template-columns: auto auto auto auto auto auto; 23 | } 24 | 25 | .btn1{ 26 | width: 6em; 27 | height: 3em; 28 | transform: translate(60em, 0px); 29 | } 30 | 31 | .class1{ 32 | border :1px solid black; 33 | font-size: 3rem; 34 | display: flex; 35 | justify-content: center; 36 | align-items: center; 37 | margin: 2px; 38 | } 39 | 40 | .even{ 41 | background-color: green; 42 | } 43 | 44 | .odd{ 45 | background-color: yellow; 46 | } 47 | 48 | .prime{ 49 | background-color: red; 50 | } -------------------------------------------------------------------------------- /Day22_Manipulating_DOM_level1_solution/numberDisplay.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | exercise1 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Day22_Manipulating_DOM_level1_solution/numberDisplay.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | const btn = document.querySelector(".btn1"); 4 | const box = document.querySelector(".container"); 5 | let i=0, is_prime; 6 | 7 | function start(){ 8 | for(i=0; i<26; i++){ 9 | 10 | const newdiv = document.createElement("div"); 11 | newdiv.innerText = i; 12 | newdiv.classList.add("class1"); 13 | 14 | for(let j = 2; j 2 | 3 | 4 | 5 | 30DaysOfJavaScript:22 Day: Number Generator 6 | 7 | 8 | 9 | 10 |

Number Generator

11 |

30DaysOfJavaScript:DOM Day 3

12 |

Author: Asabeneh Yetayeh

13 |
14 |
15 |

16 |
17 | 18 |
19 | 20 | 21 |
22 |
23 | 24 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Day23_EventListeners/project1_NumbersGenerator/main.js: -------------------------------------------------------------------------------- 1 | document.body.style.fontFamily = 'san-serif'; 2 | let h1 = document.querySelector('h1'); 3 | let h2 = document.querySelector('h2'); 4 | let h3 = document.querySelector('h3'); 5 | 6 | h1.className = 'header'; 7 | h2.className = 'header'; 8 | h3.className = 'header'; 9 | 10 | // helper function 11 | let isPrime = num => { 12 | if (num == 1 || num == 0) return false; 13 | if (num == 2 || num == 3) 14 | return true; 15 | 16 | for (let i = 2; i <= Math.sqrt(num); i++) { 17 | if (num % i == 0) return false; 18 | } 19 | return true; 20 | } 21 | // headers styling 22 | let stdFontWeight = 400; 23 | document.querySelectorAll('.header').forEach(x => { 24 | x.style.textAlign = 'center'; 25 | x.style.fontWeight = `${stdFontWeight}`; 26 | x.style.padding = '2px'; 27 | x.style.margin = '0px'; 28 | 29 | stdFontWeight -= 30; 30 | }); 31 | h2.style.textDecoration = 'underline'; 32 | h1.style.color = 'green'; 33 | 34 | let container = document.createElement('div'); 35 | 36 | let table = document.createElement('table'); 37 | 38 | function generateNumbers(numCount) { 39 | nums = 0; 40 | while (nums < numCount) { 41 | // create table row 42 | let row = document.createElement('tr'); 43 | 44 | let x = 1; 45 | let iterationCount = numCount - nums > 6 ? 6: numCount - nums; 46 | while(x <= iterationCount) { 47 | // for (let x = 1; x <= 6; x++) { 48 | // create table data 49 | let data = document.createElement('td'); 50 | data.textContent = nums; 51 | 52 | // style the data element 53 | data.style.margin = '2px'; 54 | data.style.padding = '5px'; 55 | 56 | // selective styling 57 | if (isPrime(nums)) { 58 | data.style.backgroundColor = '#f76262'; 59 | } else if (nums % 2 !== 0) { 60 | data.style.backgroundColor = '#fee904'; 61 | } else data.style.backgroundColor = '#42b845'; 62 | 63 | // end styling 64 | row.appendChild(data); 65 | nums++; 66 | x++; 67 | } 68 | // add row to the table 69 | table.appendChild(row); 70 | } 71 | } 72 | // logic 73 | // end of helper functions 74 | let msg = document.querySelector('#message'); 75 | let inputArea = document.querySelector('input'); 76 | inputArea.addEventListener('keypress', key=>{ 77 | let val = parseInt(inputArea.value); 78 | if(val < 0 || val > 1000) { 79 | msg.textContent = 'Please enter a number between 1-1000!'; 80 | } else msg.textContent = ''; 81 | }) 82 | 83 | let button = document.querySelector('#button_1'); 84 | 85 | button.addEventListener('click', ()=>{ 86 | table.innerHTML = ''; 87 | let inputValue = parseInt(inputArea.value); 88 | 89 | if(inputValue > 1000 || inputValue < 0) { 90 | msg.textContent = 'Enter a valid number between 1 and 1000.'; 91 | } 92 | else generateNumbers(inputValue); 93 | }) 94 | // table styling 95 | table.style.width = '60%'; 96 | table.style.marginRight = '20%'; 97 | table.style.marginLeft = '20%'; 98 | table.style.marginTop = '1pc'; 99 | table.style.textAlign = 'center'; 100 | table.style.fontFamily = 'ariel'; 101 | table.style.fontSize = '15px'; 102 | table.style.fontWeight = 'bold'; 103 | table.style.color = 'white'; 104 | 105 | container.appendChild(table); 106 | document.body.appendChild(container); 107 | -------------------------------------------------------------------------------- /Day23_EventListeners/project1_NumbersGenerator/style.css: -------------------------------------------------------------------------------- 1 | /*Globals*/ 2 | body { 3 | margin: 0; 4 | padding: 0; 5 | font-family: Arial, Helvetica, sans-serif; 6 | } 7 | 8 | p { 9 | margin: 0; 10 | padding: 0; 11 | font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 12 | } 13 | .wrapper { 14 | width: 60%; 15 | margin: auto; 16 | } 17 | 18 | .wrapper #response, #input { 19 | margin-left: 23%; 20 | font-weight: 300; 21 | color: red; 22 | font-size: 0.6em; 23 | margin-bottom: 1px; 24 | } 25 | 26 | #input #button_1 { 27 | color: #fff; 28 | background-color: #73a657; 29 | margin-left: 2px; 30 | font-weight: 500; 31 | padding: 2px; 32 | border: 1px #73a657 solid; 33 | border-radius: 4px; 34 | } 35 | 36 | #input input { 37 | border: 2px #73a657 solid; 38 | border-radius: 4px; 39 | padding: 1px; 40 | } 41 | 42 | #input #bar { 43 | font-family: 'Courier New', Courier, monospace; 44 | font-weight: 700; 45 | padding-left: 5px; 46 | margin-right: 2px; 47 | } 48 | 49 | #input #button_1:hover { 50 | color: #73a657; 51 | background-color: #fff; 52 | } 53 | -------------------------------------------------------------------------------- /Day23_EventListeners/project2_ASCII_CodeVisualiser/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 30 Days of JavaScript: Day 3 8 | 9 | 10 | 11 | 12 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /Day25 Mini_Project: Solution_to_World_Countries_Data_Visualization_1/readme.txt: -------------------------------------------------------------------------------- 1 | This file contains HTML, CSS and JS code for the solution of World Countries Data Visualization 1 of 2 | Day 25. This can further be improved by the user. 3 | -------------------------------------------------------------------------------- /Day25 Mini_Project: Solution_to_World_Countries_Data_Visualization_1/visualizingData.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin: 0px; 3 | padding: 0px; 4 | box-sizing: border-box; 5 | } 6 | 7 | .top{ 8 | background-color: aliceblue; 9 | /* border: 1px solid black; */ 10 | height: 10em; 11 | text-align: center; 12 | padding: 2em; 13 | box-shadow: 0px 2px 2px; 14 | } 15 | 16 | h1{ 17 | color: orange; 18 | font-size: 400%; 19 | } 20 | 21 | .top p{ 22 | font-size: 150%; 23 | color:rgb(175, 117, 75); 24 | } 25 | 26 | .middle{ 27 | /* border :1px solid black; */ 28 | height: 8em; 29 | text-align: center; 30 | padding: 2%; 31 | } 32 | 33 | .middle p{ 34 | /* font-size: 1.em; */ 35 | margin-top: 1%; 36 | 37 | } 38 | 39 | .btn{ 40 | height: 4em; 41 | width: 8em; 42 | border-radius: 10px; 43 | margin-left: 1em; 44 | background-color: orange; 45 | } 46 | 47 | .btn:hover{ 48 | cursor: pointer; 49 | } 50 | 51 | .btn:active{ 52 | transform: scale(1.05); 53 | box-shadow: 0px 2px 2px 0px; 54 | } 55 | 56 | .container{ 57 | border-top: 2px solid black; 58 | height: 23rem; 59 | display: flex; 60 | background-color: aliceblue; 61 | box-shadow: 2px 2px 2px 2px; 62 | /* padding: 1rem; */ 63 | } 64 | 65 | .data1{ 66 | height: 100%; 67 | /* border: 1px solid red; */ 68 | width: 25%; 69 | display: grid; 70 | text-align: right; 71 | padding-right: 5rem; 72 | padding-top: 1rem; 73 | 74 | } 75 | 76 | .data1::before{ 77 | content: "Country"; 78 | text-decoration: underline; 79 | } 80 | 81 | .country{ 82 | /* border :1px solid black; */ 83 | margin-top: 3px; 84 | } 85 | 86 | .data2{ 87 | height: 100%; 88 | /* border: 1px solid red; */ 89 | width: 50%; 90 | display: grid; 91 | text-align: center; /*watchout this line */ 92 | padding-right: 5rem; 93 | /* padding-top: 1rem; */ 94 | 95 | } 96 | 97 | .data2::before{ 98 | content: "graph"; 99 | text-decoration: underline; 100 | } 101 | 102 | .data3{ 103 | height: 100%; 104 | /* border: 1px solid red; */ 105 | width: 25%; 106 | display: grid; 107 | text-align: left; 108 | padding-right: 5rem; 109 | padding-top: 1rem; 110 | 111 | 112 | } 113 | 114 | .data3::before{ 115 | content: "Stats"; 116 | text-decoration: underline; 117 | } 118 | 119 | 120 | 121 | .fillin{ 122 | background-color: orange; 123 | } -------------------------------------------------------------------------------- /Day25 Mini_Project: Solution_to_World_Countries_Data_Visualization_1/visualizingData.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Ex2 9 | 10 | 11 | 12 |
13 |

World Countries Data

14 |

currently, we have 250 countries

15 | 16 |
17 | 18 |
19 | 20 | 21 |
22 |

23 |
24 | 25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | 38 |
39 |
40 | 41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | 52 |
53 |
54 | 55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | 66 | 67 |
68 |
69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /Day25 Mini_Project: Solution_to_World_Countries_Data_Visualization_1/visualizingData.js: -------------------------------------------------------------------------------- 1 | const btn_pop = document.querySelector(".btn_pop"); 2 | const btn_lang = document.querySelector(".btn_lang"); 3 | const dash = document.querySelector(".dash"); 4 | const data1 = document.querySelector(".data1"); 5 | const data2 = document.querySelector(".data2"); 6 | const data3 = document.querySelector(".data3"); 7 | const childd1 = data1.children; //country 8 | const childd2 = data2.children; //graph 9 | const childd3 = data3.children; //number 10 | let i,rdm,temp; 11 | 12 | 13 | function showpop(){ 14 | dash.innerText = "10 most populated countries in the world." 15 | 16 | 17 | // dash.innerText = `${childd2.length}`; 18 | 19 | for(i=0; i -1)){ 259 | down.children[i].style.display = ""; 260 | k++; 261 | }else{ 262 | down.children[i].style.display = "none"; 263 | } 264 | } 265 | if(box.value == ""){ 266 | counter.innerText = `Give a letter to search`; 267 | }else{ 268 | counter.innerText = `there are ${k} countries staring with "${box.value}"`; 269 | } 270 | }) 271 | 272 | 273 | } 274 | 275 | 276 | 277 | function randomize(){ 278 | rand.classList.toggle("clicked"); 279 | if(rand.classList.contains("clicked")){ 280 | btn2.classList.remove("clicked"); 281 | btn1.classList.remove("clicked"); 282 | } 283 | 284 | 285 | while(down.firstChild){ 286 | down.removeChild(down.firstChild); 287 | } 288 | 289 | for(i=0; i 2 | 3 | 4 | 5 | 6 | 7 | 8 | Ex3 9 | 10 | 11 | 12 |
13 | 14 |

WORLD COUTNRIES LIST

15 |

total number of countries: 193

16 |

Give a letter to search

17 |
18 | 19 | 20 | 21 | 22 |
23 |
24 | 25 |
26 |
27 | 28 |
29 | 30 | 31 |
32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Day_27_Mini_Project_Solution: Portfolio/Readme: -------------------------------------------------------------------------------- 1 | This file contains HTML, CSS and JS code for the solution of Mini project of 2 | Day 27. This can further be improved by the user. 3 | -------------------------------------------------------------------------------- /Day_27_Mini_Project_Solution: Portfolio/miniPortfolio.css: -------------------------------------------------------------------------------- 1 | *{ 2 | padding: 0px; 3 | margin: 0px; 4 | box-sizing: border-box; 5 | } 6 | 7 | @font-face { 8 | font-family: myfont1; 9 | src: url(Cakecafe.ttf); 10 | } 11 | 12 | @font-face{ 13 | font-family: myfont2; 14 | src: url(CheekyRabbit.ttf); 15 | } 16 | 17 | body{ 18 | /* background: linear-gradient(45deg, rgba(200,12,23,0.5), rgba(150,50,50,0.7)); */ 19 | padding: 0px 7em; 20 | } 21 | 22 | header{ 23 | /* border: 1px solid black; */ 24 | text-transform: capitalize; 25 | font-size: 4em; 26 | font-family:myfont1; 27 | height: 2.5em; 28 | padding: 0.5em 0px; 29 | letter-spacing: 1.5rem; 30 | /* min-width: 1065px; */ 31 | /* margin-bottom: 2%; */ 32 | } 33 | 34 | @media (max-width: 1065px){ 35 | header{ 36 | font-size: 120%; 37 | margin-bottom: 15%; 38 | } 39 | } 40 | 41 | 42 | .animate1{ 43 | position: relative; 44 | font-size: 3em; 45 | height: 2em; 46 | padding: 0.25em; 47 | background-color: rgba(151, 127, 127, 0.7); 48 | overflow: hidden; 49 | } 50 | 51 | .animate1-text{ 52 | font-family: myfont2; 53 | position: absolute; 54 | left: -4.5em; 55 | opacity: 0; 56 | } 57 | 58 | 59 | .ani1{ 60 | opacity: 1; 61 | transform: translate(5em, 0px); 62 | transition: 0.4s; 63 | } 64 | 65 | 66 | p{ 67 | font-size: 1.5em; 68 | /* height: 5em; */ 69 | height: fit-content; 70 | /* min-height: fit-content; */ 71 | padding: 0.75em 0.75em; 72 | /* border: 1px solid black; */ 73 | } 74 | 75 | .boldit{ 76 | color: black; 77 | font-weight: bolder; 78 | } 79 | 80 | .card-list{ 81 | margin-top: 2%; 82 | height: 10em; 83 | display: grid; 84 | padding: 0px 2em; 85 | grid-template-columns: repeat(auto-fill, minmax(20%,1fr)); 86 | column-gap: 9em; 87 | /* border: 1px solid black; */ 88 | } 89 | 90 | .card{ 91 | min-height: 2em; 92 | font-size: 1.5em; 93 | border: 1px solid white; 94 | display: flex; 95 | justify-content: center; 96 | align-items: center; 97 | background-color: rgb(126, 119, 109); 98 | } 99 | 100 | .card:hover{ 101 | background-color: rgba(175, 157, 157, 0.4); 102 | transform: scale(1.1); 103 | } 104 | 105 | .animate2{ 106 | font-size: 2.5em; 107 | margin-top: 1em; 108 | height: 2.1em; 109 | } 110 | 111 | @media (max-width:1020px ) { 112 | 113 | .card-list{ 114 | grid-template-columns: repeat(auto-fill, minmax(40%,1fr)); 115 | margin-top: 6%; 116 | height: fit-content; 117 | row-gap: 3%; 118 | 119 | } 120 | 121 | } 122 | 123 | @media (max-width: 781px){ 124 | 125 | p{ 126 | font-size: 1.25em; 127 | margin-bottom: 10%; 128 | } 129 | 130 | } -------------------------------------------------------------------------------- /Day_27_Mini_Project_Solution: Portfolio/miniPortfolio.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ex4 9 | 10 | 11 | 12 |
bhaskar thakulla
13 | 14 |
15 | 16 |
animations
17 | 18 |
19 | 20 |

I'm Bhaskar, an accomplished IT professional with a passion for leveraging technology to drive innovation and deliver exceptional results. 21 | With one years of experience in the industry, 22 | I have established a solid track record of success in implementing cutting-edge solutions, 23 | and optimizing operational efficiency.

24 | 25 |
26 |
card goes here1
27 |
card goes here2
28 |
card goes here3
29 |
30 | 31 |
final animation.
32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Day_27_Mini_Project_Solution: Portfolio/miniPortfolio.js: -------------------------------------------------------------------------------- 1 | const animate1 = document.querySelector(".animate1"); 2 | const animate1_text = document.querySelector(".animate1-text"); 3 | const animate2_text = document.querySelector(".animate2-text"); 4 | const jobs = ['Programmer', "Student", "Footballer", "Instructor", "Anything"]; 5 | const subjects = ['Math', 'Science', 'English', 'Nepali', 'english', 'science', 'optionalmath', 'computer', 'basketball']; 6 | const colorfor = ['red','blue','green','white','brown','grey','yellow','pink','purple']; 7 | let i=0, k=0,z=0; 8 | 9 | const interval1 = setInterval(() => { 10 | if(i>jobs.length){ 11 | i=0; 12 | } 13 | if(k>=jobs.length){ 14 | k=0; 15 | } 16 | if(z==subjects.length){ 17 | z=0; 18 | } 19 | if(i%2==0){ 20 | animate1_text.innerText = jobs[k]; 21 | animate1_text.classList.add("ani1"); 22 | k++; 23 | animate2_text.innerText = subjects[z]; 24 | animate2_text.style.color = `${colorfor[z]}`; 25 | z++; 26 | }else{ 27 | animate1_text.classList.remove("ani1"); 28 | animate2_text.innerText=""; 29 | } 30 | 31 | i++; 32 | 33 | }, 1000); 34 | 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### _[30 Days of JavaScript](https://www.google.com/url?q=https://github.com/Asabeneh/30-Days-Of-JavaScript&sa=U&ved=2ahUKEwj7_ar0-9ztAhXbh1wKHfhIAuAQFjAAegQICxAB&usg=AOvVaw1GARSkJT8iPUVmodfm-Ffv)_ is a step by step guide to master JavaScript with bit-sized learning exercises. ### 2 | 3 | In this repository, I will be sharing my solutions to the exercise challenges presented at the end of each day's learning. 4 | **NOTE:** _This repository should only be considered as an educational resource, setup to tracking one's progress and hence, should not be **_Forked_**._ 5 | 6 | #### My Progress... #### 7 | :ballot_box_with_check: 01 Introduction
8 | :ballot_box_with_check: 02 Data Types
9 | :ballot_box_with_check: 03 Booleans Operators Date
10 | :ballot_box_with_check: 04 Conditionals
11 | :ballot_box_with_check: 05 Arrays
12 | :ballot_box_with_check: 06 Loops
13 | :ballot_box_with_check: 07 Functions
14 | :ballot_box_with_check: 08 Objects
15 | :ballot_box_with_check: 09 Higher Order Functions
16 | :ballot_box_with_check: 10 Sets and Maps
17 | :ballot_box_with_check: 11 Destructuring and Spreading
18 | :ballot_box_with_check: 12 Regular Expressions
19 | :ballot_box_with_check: 13 Console Object Methods
20 | :ballot_box_with_check: 14 Error Handling
21 | :ballot_box_with_check: 15 Classes
22 | :ballot_box_with_check: 16 JSON
23 | :ballot_box_with_check: 17 Web Storages
24 | 18 Promises
25 | :ballot_box_with_check: 19 Closure
26 | :ballot_box_with_check: 20 Writing Clean Code
27 | :ballot_box_with_check: 21 DOM
28 | :ballot_box_with_check: 22 Manipulating DOM Object
29 | :ballot_box_with_check: 23 Event Listeners 30 | 24 Mini Project: Solar System
31 | 25 Mini Project: World Countries Data Visualization 1
32 | 26 Mini Project: World Countries Data Visualization 33 | 2
34 | 27 Mini Project: Portfolio
35 | 28 Mini Project: Leaderboard
36 | 29 Mini Project: Animated characters
37 | 30 **FINAL PROJECTS**
38 | 39 | **_Note: I will add relative links shortly_** 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | --------------------------------------------------------------------------------