diff --git a/.gitignore b/.gitignore index cdf6fd9..fa0dfa4 100644 --- a/.gitignore +++ b/.gitignore @@ -14,23 +14,6 @@ day9.md day10.md 01_02_03_days_backup.md test.md -12_Day -13_Day -14_Day -15_Day -16_Day -17_Day -18_Day -19_Day -20_Day -21_Day -22_Day -23_Day -24_Day -25_Day -26_Day -27_Day -28_Day -29_Day -30_Day -test.html \ No newline at end of file +31_Day +test.html +res.js \ No newline at end of file diff --git a/01_Day/01_day_starter/varaible.js b/01_Day/01_day_starter/varaible.js deleted file mode 100644 index f5872af..0000000 --- a/01_Day/01_day_starter/varaible.js +++ /dev/null @@ -1,17 +0,0 @@ -// Declaring different variables of different data types -let firstName = 'Asabeneh' // first name of a person -let lastName = 'Yetayeh' // last name of a person -let country = 'Finland' // country -let city = 'Helsinki' // capital city -let age = 100 // age in years -let isMarried = true - -// Declaring variables with number values -const gravity = 9.81 // earth gravity in m/s2 -const boilingPoint = 100 // water boiling point, temperature in oC -const PI = 3.14 // geometrical constant - -// Variables can also be declaring in one line separated by comma -let name = 'Asabeneh', //name of a person - job = 'teacher', - live = 'Finland' diff --git a/01_Day/01_day_starter/helloworld.js b/01_Day_Introduction/01_day_starter/helloworld.js similarity index 100% rename from 01_Day/01_day_starter/helloworld.js rename to 01_Day_Introduction/01_day_starter/helloworld.js diff --git a/01_Day/01_day_starter/index.html b/01_Day_Introduction/01_day_starter/index.html similarity index 100% rename from 01_Day/01_day_starter/index.html rename to 01_Day_Introduction/01_day_starter/index.html diff --git a/01_Day/01_day_starter/introduction.js b/01_Day_Introduction/01_day_starter/introduction.js similarity index 100% rename from 01_Day/01_day_starter/introduction.js rename to 01_Day_Introduction/01_day_starter/introduction.js diff --git a/01_Day/01_day_starter/main.js b/01_Day_Introduction/01_day_starter/main.js similarity index 56% rename from 01_Day/01_day_starter/main.js rename to 01_Day_Introduction/01_day_starter/main.js index 4704eb2..2b952bc 100644 --- a/01_Day/01_day_starter/main.js +++ b/01_Day_Introduction/01_day_starter/main.js @@ -1,3 +1,4 @@ +// the variable values can be accessed from other variable.js file console.log(firstName, lastName, country, city, age, isMarried) console.log(gravity, boilingPoint, PI) // 9.81, 100, 3.14 console.log(name, job, live) \ No newline at end of file diff --git a/01_Day_Introduction/01_day_starter/varaible.js b/01_Day_Introduction/01_day_starter/varaible.js new file mode 100644 index 0000000..62558cb --- /dev/null +++ b/01_Day_Introduction/01_day_starter/varaible.js @@ -0,0 +1,20 @@ +// Declaring different variables of different data types + +let firstName = 'Asabeneh' // first name of a person +let lastName = 'Yetayeh' // last name of a person +let country = 'Finland' // country +let city = 'Helsinki' // capital city +let age = 100 // age in years +let isMarried = true + +// Declaring variables with number values + +const gravity = 9.81 // earth gravity in m/s2 +const boilingPoint = 100 // water boiling point, temperature in oC +const PI = 3.14 // geometrical constant + +// Variables can also be declaring in one line separated by comma + +let name = 'Asabeneh', //name of a person + job = 'teacher', + live = 'Finland' diff --git a/01_Day/variable.js b/01_Day_Introduction/variable.js similarity index 100% rename from 01_Day/variable.js rename to 01_Day_Introduction/variable.js diff --git a/02_Day/02_day_data_types.md b/02_Day_Data_types/02_day_data_types.md similarity index 60% rename from 02_Day/02_day_data_types.md rename to 02_Day_Data_types/02_day_data_types.md index 05d1cc0..198ae2b 100644 --- a/02_Day/02_day_data_types.md +++ b/02_Day_Data_types/02_day_data_types.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Data Types

@@ -14,48 +14,51 @@
-[<< Day 1](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/readMe.md) | [Day 3 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/03_Day/03_booleans_operators_date.md) +[<< Day 1](../readMe.md) | [Day 3 >>](../03_Day_Booleans_operators_date/03_booleans_operators_date.md) ![Thirty Days Of JavaScript](../images/banners/day_1_2.png) -- [📔 Day 2](#%f0%9f%93%94-day-2) - - [Data types](#data-types) +- [📔 Day 2](#-day-2) + - [Data Types](#data-types) - [Primitive Data Types](#primitive-data-types) - [Non-Primitive Data Types](#non-primitive-data-types) - [Numbers](#numbers) - - [Declaring number data types](#declaring-number-data-types) + - [Declaring Number Data Types](#declaring-number-data-types) - [Math Object](#math-object) - - [Random number generator](#random-number-generator) + - [Random Number Generator](#random-number-generator) - [Strings](#strings) - [String Concatenation](#string-concatenation) - - [Concatenating using addition operator](#concatenating-using-addition-operator) + - [Concatenating Using Addition Operator](#concatenating-using-addition-operator) - [Long Literal Strings](#long-literal-strings) - - [Escape Sequences in string](#escape-sequences-in-string) - - [Template Literals(Template Strings)](#template-literalstemplate-strings) + - [Escape Sequences in Strings](#escape-sequences-in-strings) + - [Template Literals (Template Strings)](#template-literals-template-strings) - [String Methods](#string-methods) - - [Checking Data types and Casting](#checking-data-types-and-casting) - - [Checking data types](#checking-data-types) - - [Changing data type(Casting)](#changing-data-typecasting) + - [Checking Data Types and Casting](#checking-data-types-and-casting) + - [Checking Data Types](#checking-data-types) + - [Changing Data Type (Casting)](#changing-data-type-casting) - [String to Int](#string-to-int) - [String to Float](#string-to-float) - [Float to Int](#float-to-int) -- [💻 Day 2: Exercises](#%f0%9f%92%bb-day-2-exercises) + - [💻 Day 2: Exercises](#-day-2-exercises) + - [Exercise: Level 1](#exercise-level-1) + - [Exercise: Level 2](#exercise-level-2) + - [Exercises: Level 3](#exercises-level-3) # 📔 Day 2 -## Data types +## Data Types -In the previous section, we mentioned a little bit about data types. Data or values have data types. Data types describe the characteristics of data. Data types can be divided into two +In the previous section, we mentioned a little bit about data types. Data or values have data types. Data types describe the characteristics of data. Data types can be divided into two: 1. Primitive data types 2. Non-primitive data types(Object References) ### Primitive Data Types -Primitive data types in JavaScript includes: +Primitive data types in JavaScript include: 1. Numbers - Integers, floats - 2. Strings - Any data under single or double quote + 2. Strings - Any data under single quote, double quote or backtick quote 3. Booleans - true or false value 4. Null - empty value or no value 5. Undefined - a declared variable without a value @@ -66,21 +69,22 @@ Non-primitive data types in JavaScript includes: 2. Functions 3. Arrays -Now, let us see what exactly mean primitive and non-primitive data types. -*Primitive* data types are immutable(non-modifiable) data types. Once a primitive data type is created we can not modify it. +Now, let us see what exactly primitive and non-primitive data types mean. +*Primitive* data types are immutable(non-modifiable) data types. Once a primitive data type is created we cannot modify it. + **Example:** ```js let word = 'JavaScript' ``` -If we try to modify the string stored in variable *word*, JavaScript will raise an error. Any data type under a single quote, double-quote, or backtick is a string data type. +If we try to modify the string stored in variable *word*, JavaScript should raise an error. Any data type under a single quote, double quote, or backtick quote is a string data type. ```js word[0] = 'Y' ``` -This expression does not change the string stored in the variable *word*. So, we can say that strings are not modifiable or immutable. +This expression does not change the string stored in the variable *word*. So, we can say that strings are not modifiable or in other words immutable. Primitive data types are compared by its values. Let us compare different data values. See the example below: ```js @@ -112,7 +116,7 @@ nums[0] = 10 console.log(nums) // [10, 2, 3] ``` -As you can see, an array in which a non-primitive data type is mutable. Non-primitive data types can not be compared by value. Even if two non-primitive data types have the same properties and values, they are not strictly equal. +As you can see, an array, which is a non-primitive data type is mutable. Non-primitive data types cannot be compared by value. Even if two non-primitive data types have the same properties and values, they are not strictly equal. ```js let nums = [1, 2, 3] @@ -132,11 +136,11 @@ role:'teaching', country:'Finland' } -console.log(userOne == userTwo) +console.log(userOne == userTwo) // false ``` -Rule of thumb, we do not compare non-primitive data types. Do not compare array, function, or object. -Non-primitive values are referred to as reference types because they are being compared by reference instead of value. Two objects are only strictly equal if they refer to the same underlying object. +Rule of thumb, we do not compare non-primitive data types. Do not compare arrays, functions, or objects. +Non-primitive values are referred to as reference types, because they are being compared by reference instead of value. Two objects are only strictly equal if they refer to the same underlying object. ```js let nums = [1, 2, 3] @@ -160,17 +164,17 @@ If you have a hard time understanding the difference between primitive data type ## Numbers Numbers are integers and decimal values which can do all the arithmetic operations. -Lets' see some examples of Numbers. +Let's see some examples of Numbers. -### Declaring number data types +### Declaring Number Data Types ```js let age = 35 -const gravity = 9.81 //we use const for non-changing values, gravitational constant in m/s2 +const gravity = 9.81 // we use const for non-changing values, gravitational constant in m/s2 let mass = 72 // mass in Kilogram const PI = 3.14 // pi a geometrical constant -//More Examples +// More Examples const boilingPoint = 100 // temperature in oC, boiling point of water which is a constant const bodyTemp = 37 // oC average human body temperature, which is a constant @@ -184,22 +188,22 @@ In JavaScript the Math Object provides a lots of methods to work with numbers. ```js const PI = Math.PI -console.log(PI) // 3.141592653589793 +console.log(PI) // 3.141592653589793 // Rounding to the closest number // if above .5 up if less 0.5 down rounding -console.log(Math.round(PI)) // 3 to round values to the nearest number +console.log(Math.round(PI)) // 3 to round values to the nearest number -console.log(Math.round(9.81)) // 10 +console.log(Math.round(9.81)) // 10 -console.log(Math.floor(PI)) // 3 rounding down +console.log(Math.floor(PI)) // 3 rounding down -console.log(Math.ceil(PI)) // 4 rounding up +console.log(Math.ceil(PI)) // 4 rounding up -console.log(Math.min(-5, 3, 20, 4,5, 10)) // -5, returns the minimum value +console.log(Math.min(-5, 3, 20, 4, 5, 10)) // -5, returns the minimum value -console.log(Math.max(-5, 3, 20, 4,5, 10)) // 20, returns the maximum value +console.log(Math.max(-5, 3, 20, 4, 5, 10)) // 20, returns the maximum value const randNum = Math.random() // creates random number between 0 to 0.999999 console.log(randNum) @@ -210,22 +214,22 @@ const num = Math.floor(Math.random () * 11) // creates random number between 0 a console.log(num) //Absolute value -console.log(Math.abs(-10)) //10 +console.log(Math.abs(-10)) // 10 //Square root console.log(Math.sqrt(100)) // 10 -console.log(Math.sqrt(2)) //1.4142135623730951 +console.log(Math.sqrt(2)) // 1.4142135623730951 // Power -console.log(Math.pow(3, 2)) // 9 +console.log(Math.pow(3, 2)) // 9 -console.log(Math.E) // 2.718 +console.log(Math.E) // 2.718 // Logarithm -//Returns the natural logarithm of base E of x, Math.log(x) -console.log(Math.log(2)) // 0.6931471805599453 -console.log(Math.log(10)) // 2.302585092994046 +// Returns the natural logarithm with base E of x, Math.log(x) +console.log(Math.log(2)) // 0.6931471805599453 +console.log(Math.log(10)) // 2.302585092994046 // Trigonometry Math.sin(0) @@ -235,15 +239,15 @@ Math.cos(0) Math.cos(60) ``` -#### Random number generator +#### Random Number Generator The JavaScript Math Object has a random() method number generator which generates number from 0 to 0.999999999... ```js -let randomNum = Math.random() // generates 0 to 0.999 +let randomNum = Math.random() // generates 0 to 0.999... ``` -Now, let us see how we can use random() method to generate a random number between 0 and 10 inclusive. +Now, let us see how we can use random() method to generate a random number between 0 and 10: ```js let randomNum = Math.random() // generates 0 to 0.999 @@ -257,8 +261,8 @@ console.log(randomNumRoundToFloor) // this gives between 0 and 10 ## Strings -Strings are texts, which are under **_single_** or **_double_** quote. To declare a string, we need a variable name, assignment operator, a value under a single quote, double-quote, or backtick. -Lets' see some examples of string: +Strings are texts, which are under **_single_** , **_double_**, **_back-tick_** quote. To declare a string, we need a variable name, assignment operator, a value under a single quote, double quote, or backtick quote. +Let's see some examples of strings: ```js let space = ' ' // an empty space string @@ -268,22 +272,14 @@ let country = 'Finland' let city = 'Helsinki' let language = 'JavaScript' let job = 'teacher' +let quote = "The saying,'Seeing is Believing' is not correct in 2020." +let quotWithBackTick = `The saying,'Seeing is Believing' is not correct in 2020.` ``` ### String Concatenation -Connect two or more strings together is called concatenation. - -```js -// Declaring different variables of different data types -let space = ' ' -let firstName = 'Asabeneh' -let lastName = 'Yetayeh' -let country = 'Finland' -let city = 'Helsinki' -let language = 'JavaScript' -let job = 'teacher' -``` +Connecting two or more strings together is called concatenation. +Using the strings declared in the previous String section: ```js let fullName = firstName + space + lastName; // concatenation, merging two string together. @@ -294,11 +290,11 @@ console.log(fullName); Asabeneh Yetayeh ``` -We can concatenate string in different ways. +We can concatenate strings in different ways. -#### Concatenating using addition operator +#### Concatenating Using Addition Operator -Concatenating using the addition operator is an old way. This way of concatenating is tedious and error-prone. It is good to know how to concatenate this way, but I strongly suggest to use the second way. +Concatenating using the addition operator is an old way. This way of concatenating is tedious and error-prone. It is good to know how to concatenate this way, but I strongly suggest to use the ES6 template strings (explained later on). ```js // Declaring different variables of different data types @@ -310,9 +306,10 @@ let city = 'Helsinki' let language = 'JavaScript' let job = 'teacher' let age = 250 -let fullName = firstName + space + lastName -let personInfoOne = fullName + '. I am ' + age + '. I live in ' + country; // ES5 + +let fullName =firstName + space + lastName +let personInfoOne = fullName + '. I am ' + age + '. I live in ' + country; // ES5 string addition console.log(personInfoOne) ``` @@ -335,35 +332,52 @@ to global audience and I started a Python challenge from November 20 - December It was one of the most rewarding and inspiring experience.\ Now, we are in 2020. I am enjoying preparing the 30DaysOfJavaScript challenge and \ I hope you are enjoying too." + console.log(paragraph) ``` -#### Escape Sequences in string +#### Escape Sequences in Strings -In JavaScript and other programming language \ followed by some characters is an escape sequence. Let's see the most common escape characters: +In JavaScript and other programming languages \ followed by some characters is an escape sequence. Let's see the most common escape characters: - \n: new line -- \t: Tab means(8 spaces) +- \t: Tab, means 8 spaces - \\\\: Back slash - \\': Single quote (') -- \\":Double quote (") +- \\": Double quote (") ```js -console.log('I hope every one is enjoying the 30 Days Of JavaScript challenge.\nDo you ?') // line break +console.log('I hope everyone is enjoying the 30 Days Of JavaScript challenge.\nDo you ?') // line break console.log('Days\tTopics\tExercises') console.log('Day 1\t3\t5') console.log('Day 2\t3\t5') console.log('Day 3\t3\t5') console.log('Day 4\t3\t5') -console.log('This is a back slash symbol (\\)') // To write a back slash +console.log('This is a backslash symbol (\\)') // To write a backslash console.log('In every programming language it starts with \"Hello, World!\"') console.log("In every programming language it starts with \'Hello, World!\'") -console.log('The saying \'Seeing is Believing\' is\'t correct in 2020') +console.log('The saying \'Seeing is Believing\' isn\'t correct in 2020') +``` + +Output in console: + +```sh +I hope everyone is enjoying the 30 Days Of JavaScript challenge. +Do you ? +Days Topics Exercises +Day 1 3 5 +Day 2 3 5 +Day 3 3 5 +Day 4 3 5 +This is a backslash symbol (\) +In every programming language it starts with "Hello, World!" +In every programming language it starts with 'Hello, World!' +The saying 'Seeing is Believing' isn't correct in 2020 ``` -#### Template Literals(Template Strings) +#### Template Literals (Template Strings) -To create a template string, we use two backticks. We can inject data as expression inside a template string. To inject data, we enclose the expression with a curly bracket({}) followed by a $ sign. See the syntax below. +To create a template strings, we use two back-ticks. We can inject data as expressions inside a template string. To inject data, we enclose the expression with a curly bracket({}) preceded by a $ sign. See the syntax below. ```js //Syntax @@ -403,7 +417,7 @@ I am Asabeneh Yetayeh. I am 250. I live in Finland. I am Asabeneh Yetayeh. I live in Helsinki, Finland. I am a teacher. I teach JavaScript. ``` -Using a string template or string interpolation method, we can add expression, which could be a value or some operations(comparison, arithmetic operations, ternary operation). +Using a string template or string interpolation method, we can add expressions, which could be a value, or some operations (comparison, arithmetic operations, ternary operation). ```js let a = 2 @@ -417,19 +431,20 @@ console.log(`${a} is greater than ${b}: ${a > b}`) ### String Methods -Everything in JavaScript is an object. A string is a primitive data type that means we can not modify once it is created. The string object has many string methods. There are different string methods that can help us to work with strings. +Everything in JavaScript is an object. A string is a primitive data type that means we can not modify it once it is created. The string object has many string methods. There are different string methods that can help us to work with strings. 1. *length*: The string *length* method returns the number of characters in a string included empty space. - **Example:** - ```js - let js = 'JavaScript' - console.log(js.length) // 10 - let firstName = 'Asabeneh' - console.log(firstName.length) // 8 - ``` +**Example:** + +```js +let js = 'JavaScript' +console.log(js.length) // 10 +let firstName = 'Asabeneh' +console.log(firstName.length) // 8 +``` -2. *Accessing characters in a string*: We can access each character in a string using its index. In programming, counting starts from 0. The first index of the string is zero, and the last index is one minus the length of the string. +2. *Accessing characters in a string*: We can access each character in a string using its index. In programming, counting starts from 0. The first index of the string is zero, and the last index is the length of the string minus one. ![Accessing sting by index](../images/string_indexes.png) @@ -453,7 +468,7 @@ console.log(lastIndex) // 9 console.log(string[lastIndex]) // t ``` -1. *toUpperCase()*: this method changes the string to uppercase letters. +3. *toUpperCase()*: this method changes the string to uppercase letters. ```js let string = 'JavaScript' @@ -495,7 +510,7 @@ let country = 'Finland' console.log(country.substr(3, 4)) // land ``` -6. *substring()*: It takes two arguments, the starting index and the stopping index but it doesn't include the stopping index. +6. *substring()*: It takes two arguments, the starting index and the stopping index but it doesn't include the character at the stopping index. ```js let string = 'JavaScript' @@ -516,17 +531,17 @@ console.log(country.substring(3)) // land ```js let string = '30 Days Of JavaScript' -console.log(string.split()) // ["30 Days Of JavaScript"] -console.log(string.split(' ')) // ["30", "Days", "Of", "JavaScript"] +console.log(string.split()) // Changes to an array -> ["30 Days Of JavaScript"] +console.log(string.split(' ')) // Split to an array at space -> ["30", "Days", "Of", "JavaScript"] let firstName = 'Asabeneh' -console.log(firstName.split()) // ["Asabeneh"] -console.log(firstName.split('')) // ["A", "s", "a", "b", "e", "n", "e", "h"] +console.log(firstName.split()) // Change to an array - > ["Asabeneh"] +console.log(firstName.split('')) // Split to an array at each letter -> ["A", "s", "a", "b", "e", "n", "e", "h"] let countries = 'Finland, Sweden, Norway, Denmark, and Iceland' -console.log(countries.split(',')) // ["Finland", " Sweden", " Norway", " Denmark", " and Iceland"] +console.log(countries.split(',')) // split to any array at comma -> ["Finland", " Sweden", " Norway", " Denmark", " and Iceland"] console.log(countries.split(', ')) //  ["Finland", "Sweden", "Norway", "Denmark", "and Iceland"] ``` @@ -535,13 +550,13 @@ console.log(countries.split(', ')) //  ["Finland", "Sweden", "Norway", "Denmark ```js let string = ' 30 Days Of JavaScript ' -console.log(string) +console.log(string) console.log(string.trim(' ')) let firstName = ' Asabeneh ' console.log(firstName) -console.log(firstName.trim()) +console.log(firstName.trim()) // still removes spaces at the beginning and the end of the string ``` ```sh @@ -551,13 +566,13 @@ console.log(firstName.trim()) Asabeneh ``` -9. *includes()*: It takes a substring argument and it check if substring argument exists in the string. *includes()* returns a boolean. It checks if a substring exist in a string and it returns true if it exists and false if it doesn't exist. +9. *includes()*: It takes a substring argument and it checks if substring argument exists in the string. *includes()* returns a boolean. If a substring exist in a string, it returns true, otherwise it returns false. ```js let string = '30 Days Of JavaScript' console.log(string.includes('Days')) // true -console.log(string.includes('days')) // false +console.log(string.includes('days')) // false - it is case sensitive! console.log(string.includes('Script')) // true console.log(string.includes('script')) // false console.log(string.includes('java')) // false @@ -571,7 +586,7 @@ console.log(country.includes('land')) // true console.log(country.includes('Land')) // false ``` -10. *replace()*: takes to parameter the old substring and new substring. +10. *replace()*: takes as a parameter the old substring and a new substring. ```js string.replace(oldsubstring, newsubstring) @@ -599,7 +614,7 @@ let lastIndex = string.length - 1 console.log(string.charAt(lastIndex)) // t ``` -12. *charCodeAt()*: Takes index and it returns char code(ASCII number) of the value at that index +12. *charCodeAt()*: Takes index and it returns char code (ASCII number) of the value at that index ```js string.charCodeAt(index) @@ -607,14 +622,14 @@ string.charCodeAt(index) ```js let string = '30 Days Of JavaScript' -console.log(string.charCodeAt(3)) // D ASCII number is 51 +console.log(string.charCodeAt(3)) // D ASCII number is 68 let lastIndex = string.length - 1 console.log(string.charCodeAt(lastIndex)) // t ASCII is 116 ``` -13. *indexOf()*: Takes takes a substring and if the substring exists in a string it returns the first position of the substring if does not exist it returns -1 +13. *indexOf()*: Takes a substring and if the substring exists in a string it returns the first position of the substring if does not exist it returns -1 ```js string.indexOf(substring) @@ -632,10 +647,12 @@ console.log(string.indexOf('Script')) //15 console.log(string.indexOf('script')) // -1 ``` -14. *lastIndexOf()*: Takes takes a substring and if the substring exists in a string it returns the last position of the substring if it does not exist it returns -1 +14. *lastIndexOf()*: Takes a substring and if the substring exists in a string it returns the last position of the substring if it does not exist it returns -1 + ```js -string.lastIndexOf(index) +//syntax +string.lastIndexOf(substring) ``` ```js @@ -646,7 +663,7 @@ console.log(string.lastIndexOf('you')) // 63 console.log(string.lastIndexOf('JavaScript')) // 38 ``` -15. *concat()*: it takes many substrings and creates concatenation. +15. *concat()*: it takes many substrings and joins them. ```js string.concat(substring, substring, substring) @@ -681,18 +698,18 @@ console.log(country.startsWith('fin')) // false console.log(country.startsWith('land')) // false ``` -17. *endsWith*: it takes a substring as an argument and it checks if the string starts with that specified substring. It returns a boolean(true or false). +17. *endsWith*: it takes a substring as an argument and it checks if the string ends with that specified substring. It returns a boolean(true or false). ```js string.endsWith(substring) ``` ```js -let string = 'Love is the best to in this world' +let string = 'Love is the most powerful feeling in the world' console.log(string.endsWith('world')) // true console.log(string.endsWith('love')) // false -console.log(string.endsWith('in this world')) // true +console.log(string.endsWith('in the world')) // true let country = 'Finland' @@ -701,7 +718,7 @@ console.log(country.endsWith('fin')) // false console.log(country.endsWith('Fin')) // false ``` -18. *search*: it takes a substring as an argument and it returns the index of the first match. +18. *search*: it takes a substring as an argument and it returns the index of the first match. The search value can be a string or a regular expression pattern. ```js string.search(substring) @@ -709,7 +726,8 @@ string.search(substring) ```js let string = 'I love JavaScript. If you do not love JavaScript what else can you love.' -console.log(string.search('love')) // 2 +console.log(string.search('love')) // 2 +console.log(string.search(/javascript/gi)) // 7 ``` 19. *match*: it takes a substring or regular expression pattern as an argument and it returns an array if there is match if not it returns null. Let us see how a regular expression pattern looks like. It starts with / sign and ends with / sign. @@ -741,10 +759,10 @@ let pattern = /love/gi console.log(string.match(pattern)) // ["love", "love", "love"] ``` -Let us extract numbers from text using regular expression. This is not regular expression section, no panic, we will cover regular expression in other section. +Let us extract numbers from text using a regular expression. This is not the regular expression section, do not panic! We will cover regular expressions later on. ```js -let txt = 'In 2019, I run 30 Days of Python. Now, in 2020 I super exited to start this challenge' +let txt = 'In 2019, I ran 30 Days of Python. Now, in 2020 I am super exited to start this challenge' let regEx = /\d+/ // d with escape character means d not a normal d instead acts a digit @@ -755,7 +773,7 @@ console.log(txt.match(regEx)) // ["2", "0", "1", "9", "3", "0", "2", "0", "2", console.log(txt.match(/\d+/g)) // ["2019", "30", "2020"] ``` -20. *repeat()*: it takes a number argument and it returned the repeated version of the string. +20. *repeat()*: it takes a number as argument and it returns the repeated version of the string. ```js string.repeat(n) @@ -766,12 +784,13 @@ let string = 'love' console.log(string.repeat(10)) // lovelovelovelovelovelovelovelovelovelove ``` -## Checking Data types and Casting +## Checking Data Types and Casting -### Checking data types +### Checking Data Types -- Check Data types: To check the data type of a certain data type we use the _typeof_ and we also change one data type to another. - **Example:** +To check the data type of a certain variable we use the _typeof_ method. + +**Example:** ```js // Different javascript data types @@ -796,14 +815,14 @@ console.log(typeof undefined) // undefined console.log(typeof null) // object ``` -### Changing data type(Casting) +### Changing Data Type (Casting) -- Casting: Converting one data type to another data type. We use _parseInt()_, _parsefloat()_,_Number()_, _+ sign_, _str()_ +- Casting: Converting one data type to another data type. We use _parseInt()_, _parseFloat()_, _Number()_, _+ sign_, _str()_ When we do arithmetic operations string numbers should be first converted to integer or float if not it returns an error. #### String to Int -We can convert string number to a number. Any number inside a quote is a string number. An example of a string number: '10', '5', etc. +We can convert string number to a number. Any number inside a quote is a string number. An example of a string number: '10', '5', etc. We can convert string to number using the following methods: - parseInt() @@ -832,7 +851,7 @@ console.log(numInt) // 10 #### String to Float -We can convert string float number to a float number. Any float number inside a quote is a string float number. An example of a string float number: '9.81', '3.14', '1.44', etc. +We can convert string float number to a float number. Any float number inside a quote is a string float number. An example of a string float number: '9.81', '3.14', '1.44', etc. We can convert string float to number using the following methods: - parseFloat() @@ -874,76 +893,84 @@ let numInt = parseInt(num) console.log(numInt) // 9 ``` -🌕 You are awesome. You have just completed day 2 challenges and you are two steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle. +🌕 You are awesome. You have just completed day 2 challenges and you are two steps ahead on your way to greatness. Now do some exercises for your brain and for your muscle. + +## 💻 Day 2: Exercises -# 💻 Day 2: Exercises +### Exercise: Level 1 -1. Declare a variable name challenge and assign it to an initial value **'30 Days Of JavaScript'**. +1. Declare a variable named challenge and assign it to an initial value **'30 Days Of JavaScript'**. 2. Print the string on the browser console using __console.log()__ 3. Print the __length__ of the string on the browser console using _console.log()_ -4. Change all the string to capital letters using __toUpperCase()__ method -5. Change all the string to lowercase letters using __toLowerCase()__ method -6. Cut(slice) out the first word of the string using __substr()__ or __substring()__ method +4. Change all the string characters to capital letters using __toUpperCase()__ method +5. Change all the string characters to lowercase letters using __toLowerCase()__ method +6. Cut (slice) out the first word of the string using __substr()__ or __substring()__ method 7. Slice out the phrase *Days Of JavaScript* from *30 Days Of JavaScript*. -8. Use __substr__ to slice out the phase __because because because__ in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__ -9. Check if the string contains a word __Script__ using __includes()__ method -10. Split the __string__ into __array__ using __split()__ method -11. Split the string 30 Days Of JavaScript at the space using __split()__ method -12. 'Facebook, Google, Microsoft, Apple, IBM, Oracle, Amazon' __split__ the string at the comma and change it to an array. -13. Change 30 Days Of JavaScript to 30 Days Of Python using __replace()__ method. -14. What is character at index 15 in '30 Days Of JavaScript' string use __charAt()__ method. -15. What is the character code of J in '30 Days Of JavaScript' string using __charCodeAt()__ -16. Use __indexOf__ to determine the position of the first occurrence of a in 30 Days Of JavaScript -17. Use __lastIndexOf__ to determine the position of the last occurrence of a in 30 Days Of JavaScript. -18. Use __indexOf__ to find the position of the first occurrence of the word __because__ in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__ -19. Use __lastIndexOf__ to find the position of the last occurrence of the word __because__ in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__ -20. Use __search__ to find the position of the first occurrence of the word __because__ in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__ -21. Use __trim()__ to remove if there is trailing whitespace at the beginning and the end of a string.E.g ' 30 Days Of JavaScript '. -22. Use __startsWith()__ method with the string *30 Days Of JavaScript* make the result true -23. Use __endsWith()__ method with the string *30 Days Of JavaScript* make the result true -24. Use __match()__ method to find all the a’s in 30 Days Of JavaScript -25. Use __match()__ to count the number all because's in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__ -26. Use __concat()__ and merge '30 Days of' and 'JavaScript' to a single string, '30 Days Of JavaScript' -27. Use __repeat()__ method to print 30 Days Of JavaScript 2 times -28. ** 'Love is the best thing in this world. Some found their love and some are still looking for their love.' Count the number of word love in this sentence. -29. ** Calculate the total annual income of the person by extract the numbers from the following text. 'He earns 5000 euro from salary per month, 10000 euro annual bonus, 15000 euro online courses per month.' -30. ** Clean the following text and find the most frequent word(hint, use replace and regular express). - -```js - const sentence = '%I $am@% a %tea@cher%, &and& I lo%#ve %tea@ching%;. There $is nothing; &as& mo@re rewarding as educa@ting &and& @emp%o@wering peo@ple. ;I found tea@ching m%o@re interesting tha@n any other %jo@bs. %Do@es thi%s mo@tivate yo@u to be a tea@cher!? %Th#is 30#Days&OfJavaScript &is also $the $result of &love& of tea&ching' -``` - -31. Using console.log() print out the following statement. - -```sh -The quote 'There is no exercise better for the heart than reaching down and lifting people up.' by John Holmes teaches us to help to one another. -``` - -32. Using console.log() print out the following quote by Mother Teresa. - -```sh -"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 your hand instead." -``` - -33. Check if 'on' is found in both python and jargon -34. _I hope this course is not full of jargon_. Check if _jargon_ is in the sentence. -35. Generate a random number between 0 and 100 inclusive. -36. Generate a random number between 50 and 100 inclusive. -37. Generate a random number between 0 and 255 inclusive. -38. Access the 'JavaScript' string characters using a random number. -39. Use console.log() and escape characters to print the following pattern. - - ```js - 1 1 1 1 1 - 2 1 2 4 8 - 3 1 3 9 27 - 4 1 4 16 64 - 5 1 5 25 125 - ``` - -40. Check if typeof '10' is exactly equal to 10. If not make it exactly equal. -41. Check if parseInt('9.8') is equal to 10 if not make it exactly equal with 10. +8. Check if the string contains a word __Script__ using __includes()__ method +9. Split the __string__ into an __array__ using __split()__ method +10. Split the string 30 Days Of JavaScript at the space using __split()__ method +11. 'Facebook, Google, Microsoft, Apple, IBM, Oracle, Amazon' __split__ the string at the comma and change it to an array. +12. Change 30 Days Of JavaScript to 30 Days Of Python using __replace()__ method. +13. What is character at index 15 in '30 Days Of JavaScript' string? Use __charAt()__ method. +14. What is the character code of J in '30 Days Of JavaScript' string using __charCodeAt()__ +15. Use __indexOf__ to determine the position of the first occurrence of __a__ in 30 Days Of JavaScript +16. Use __lastIndexOf__ to determine the position of the last occurrence of __a__ in 30 Days Of JavaScript. +17. Use __indexOf__ to find the position of the first occurrence of the word __because__ in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__ +18. Use __lastIndexOf__ to find the position of the last occurrence of the word __because__ in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__ +19. Use __search__ to find the position of the first occurrence of the word __because__ in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__ +20. Use __trim()__ to remove any trailing whitespace at the beginning and the end of a string.E.g ' 30 Days Of JavaScript '. +21. Use __startsWith()__ method with the string *30 Days Of JavaScript* and make the result true +22. Use __endsWith()__ method with the string *30 Days Of JavaScript* and make the result true +23. Use __match()__ method to find all the __a__’s in 30 Days Of JavaScript +24. Use __concat()__ and merge '30 Days of' and 'JavaScript' to a single string, '30 Days Of JavaScript' +25. Use __repeat()__ method to print 30 Days Of JavaScript 2 times + +### Exercise: Level 2 + +1. Using console.log() print out the following statement: + + ```sh + The quote 'There is no exercise better for the heart than reaching down and lifting people up.' by John Holmes teaches us to help one another. + ``` + +2. Using console.log() print out the following quote by Mother Teresa: + + ```sh + "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 your hand instead." + ``` + +3. Check if typeof '10' is exactly equal to 10. If not make it exactly equal. +4. Check if parseFloat('9.8') is equal to 10 if not make it exactly equal with 10. +5. Check if 'on' is found in both python and jargon +6. _I hope this course is not full of jargon_. Check if _jargon_ is in the sentence. +7. Generate a random number between 0 and 100 inclusively. +8. Generate a random number between 50 and 100 inclusively. +9. Generate a random number between 0 and 255 inclusively. +10. Access the 'JavaScript' string characters using a random number. +11. Use console.log() and escape characters to print the following pattern. + + ```js + 1 1 1 1 1 + 2 1 2 4 8 + 3 1 3 9 27 + 4 1 4 16 64 + 5 1 5 25 125 + ``` + +12. Use __substr__ to slice out the phrase __because because because__ from the following sentence:__'You cannot end a sentence with because because because is a conjunction'__ + +### Exercises: Level 3 + +1. 'Love is the best thing in this world. Some found their love and some are still looking for their love.' Count the number of word __love__ in this sentence. +2. Use __match()__ to count the number of all __because__ in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__ +3. Clean the following text and find the most frequent word (hint, use replace and regular expressions). + + ```js + const sentence = '%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' + ``` + +4. Calculate the total annual income of the person by extracting the numbers from the following text. 'He earns 5000 euro from salary per month, 10000 euro annual bonus, 15000 euro online courses per month.' 🎉 CONGRATULATIONS ! 🎉 -[<< Day 1](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/readMe.md) | [Day 3 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/03_Day/03_booleans_operators_date.md) +[<< Day 1](../readMe.md) | [Day 3 >>](../03_Day_Booleans_operators_date/03_booleans_operators_date.md) diff --git a/02_Day/02_day_starter/index.html b/02_Day_Data_types/02_day_starter/index.html similarity index 100% rename from 02_Day/02_day_starter/index.html rename to 02_Day_Data_types/02_day_starter/index.html diff --git a/02_Day/02_day_starter/main.js b/02_Day_Data_types/02_day_starter/main.js similarity index 100% rename from 02_Day/02_day_starter/main.js rename to 02_Day_Data_types/02_day_starter/main.js diff --git a/02_Day/day_1_2.png b/02_Day_Data_types/day_1_2.png similarity index 100% rename from 02_Day/day_1_2.png rename to 02_Day_Data_types/day_1_2.png diff --git a/02_Day/math_object.js b/02_Day_Data_types/math_object.js similarity index 100% rename from 02_Day/math_object.js rename to 02_Day_Data_types/math_object.js diff --git a/02_Day/non_primitive_data_types.js b/02_Day_Data_types/non_primitive_data_types.js similarity index 100% rename from 02_Day/non_primitive_data_types.js rename to 02_Day_Data_types/non_primitive_data_types.js diff --git a/02_Day/number_data_types.js b/02_Day_Data_types/number_data_types.js similarity index 100% rename from 02_Day/number_data_types.js rename to 02_Day_Data_types/number_data_types.js diff --git a/02_Day/primitive_data_types.js b/02_Day_Data_types/primitive_data_types.js similarity index 100% rename from 02_Day/primitive_data_types.js rename to 02_Day_Data_types/primitive_data_types.js diff --git a/02_Day/string_concatenation.js b/02_Day_Data_types/string_concatenation.js similarity index 100% rename from 02_Day/string_concatenation.js rename to 02_Day_Data_types/string_concatenation.js diff --git a/02_Day/string_data_types.js b/02_Day_Data_types/string_data_types.js similarity index 100% rename from 02_Day/string_data_types.js rename to 02_Day_Data_types/string_data_types.js diff --git a/02_Day/string_methods/accessing_character.js b/02_Day_Data_types/string_methods/accessing_character.js similarity index 100% rename from 02_Day/string_methods/accessing_character.js rename to 02_Day_Data_types/string_methods/accessing_character.js diff --git a/02_Day/string_methods/char_at.js b/02_Day_Data_types/string_methods/char_at.js similarity index 100% rename from 02_Day/string_methods/char_at.js rename to 02_Day_Data_types/string_methods/char_at.js diff --git a/02_Day/string_methods/char_code_at.js b/02_Day_Data_types/string_methods/char_code_at.js similarity index 100% rename from 02_Day/string_methods/char_code_at.js rename to 02_Day_Data_types/string_methods/char_code_at.js diff --git a/02_Day/string_methods/concat.js b/02_Day_Data_types/string_methods/concat.js similarity index 100% rename from 02_Day/string_methods/concat.js rename to 02_Day_Data_types/string_methods/concat.js diff --git a/02_Day/string_methods/ends_with.js b/02_Day_Data_types/string_methods/ends_with.js similarity index 100% rename from 02_Day/string_methods/ends_with.js rename to 02_Day_Data_types/string_methods/ends_with.js diff --git a/02_Day/string_methods/includes.js b/02_Day_Data_types/string_methods/includes.js similarity index 100% rename from 02_Day/string_methods/includes.js rename to 02_Day_Data_types/string_methods/includes.js diff --git a/02_Day/string_methods/index_of.js b/02_Day_Data_types/string_methods/index_of.js similarity index 100% rename from 02_Day/string_methods/index_of.js rename to 02_Day_Data_types/string_methods/index_of.js diff --git a/02_Day/string_methods/last_index_of.js b/02_Day_Data_types/string_methods/last_index_of.js similarity index 100% rename from 02_Day/string_methods/last_index_of.js rename to 02_Day_Data_types/string_methods/last_index_of.js diff --git a/02_Day/string_methods/length.js b/02_Day_Data_types/string_methods/length.js similarity index 100% rename from 02_Day/string_methods/length.js rename to 02_Day_Data_types/string_methods/length.js diff --git a/02_Day/string_methods/match.js b/02_Day_Data_types/string_methods/match.js similarity index 84% rename from 02_Day/string_methods/match.js rename to 02_Day_Data_types/string_methods/match.js index 6e28141..54e18a8 100644 --- a/02_Day/string_methods/match.js +++ b/02_Day_Data_types/string_methods/match.js @@ -15,8 +15,8 @@ console.log(string.match(pattern)) // ["love", "love", "love"] // Let us extract numbers from text using regular expression. This is not regular expression section, no panic. let txt = 'In 2019, I run 30 Days of Pyhton. Now, in 2020 I super exited to start this challenge' -let regEx = /\d+/ // d with escape character means d not a normal d instead acts a digit +let regEx = /\d/g // d with escape character means d not a normal d instead acts a digit // + means one or more digit numbers, // if there is g after that it means global, search everywhere. -console.log(text.match(regEx)) // ["2", "0", "1", "9", "3", "0", "2", "0", "2", "0"] -console.log(text.match(/\d+/g)) // ["2019", "30", "2020"] +console.log(txt.match(regEx)) // ["2", "0", "1", "9", "3", "0", "2", "0", "2", "0"] +console.log(txt.match(/\d+/g)) // ["2019", "30", "2020"] diff --git a/02_Day/string_methods/repeat.js b/02_Day_Data_types/string_methods/repeat.js similarity index 100% rename from 02_Day/string_methods/repeat.js rename to 02_Day_Data_types/string_methods/repeat.js diff --git a/02_Day/string_methods/replace.js b/02_Day_Data_types/string_methods/replace.js similarity index 100% rename from 02_Day/string_methods/replace.js rename to 02_Day_Data_types/string_methods/replace.js diff --git a/02_Day/string_methods/search.js b/02_Day_Data_types/string_methods/search.js similarity index 100% rename from 02_Day/string_methods/search.js rename to 02_Day_Data_types/string_methods/search.js diff --git a/02_Day/string_methods/split.js b/02_Day_Data_types/string_methods/split.js similarity index 100% rename from 02_Day/string_methods/split.js rename to 02_Day_Data_types/string_methods/split.js diff --git a/02_Day/string_methods/starts_with.js b/02_Day_Data_types/string_methods/starts_with.js similarity index 100% rename from 02_Day/string_methods/starts_with.js rename to 02_Day_Data_types/string_methods/starts_with.js diff --git a/02_Day/string_methods/substr.js b/02_Day_Data_types/string_methods/substr.js similarity index 100% rename from 02_Day/string_methods/substr.js rename to 02_Day_Data_types/string_methods/substr.js diff --git a/02_Day/string_methods/substring.js b/02_Day_Data_types/string_methods/substring.js similarity index 100% rename from 02_Day/string_methods/substring.js rename to 02_Day_Data_types/string_methods/substring.js diff --git a/02_Day/string_methods/to_lowercase.js b/02_Day_Data_types/string_methods/to_lowercase.js similarity index 100% rename from 02_Day/string_methods/to_lowercase.js rename to 02_Day_Data_types/string_methods/to_lowercase.js diff --git a/02_Day/string_methods/to_uppercase.js b/02_Day_Data_types/string_methods/to_uppercase.js similarity index 100% rename from 02_Day/string_methods/to_uppercase.js rename to 02_Day_Data_types/string_methods/to_uppercase.js diff --git a/02_Day/string_methods/trim.js b/02_Day_Data_types/string_methods/trim.js similarity index 100% rename from 02_Day/string_methods/trim.js rename to 02_Day_Data_types/string_methods/trim.js diff --git a/03_Day/03_booleans_operators_date.md b/03_Day_Booleans_operators_date/03_booleans_operators_date.md similarity index 77% rename from 03_Day/03_booleans_operators_date.md rename to 03_Day_Booleans_operators_date/03_booleans_operators_date.md index 8102c39..399ec7d 100644 --- a/03_Day/03_booleans_operators_date.md +++ b/03_Day_Booleans_operators_date/03_booleans_operators_date.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Booleans, Operators, Date

@@ -13,11 +13,11 @@
-[<< Day 2](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/02_Day/02_day_data_types.md) | [Day 4 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/04_Day/04_day_conditionals.md) +[<< Day 2](../02_Day_Data_types/02_day_data_types.md) | [Day 4 >>](../04_Day_Conditionals/04_day_conditionals.md) ![Thirty Days Of JavaScript](../images/banners/day_1_3.png) -- [📔 Day 3](#%f0%9f%93%94-day-3) +- [📔 Day 3](#-day-3) - [Booleans](#booleans) - [Truthy values](#truthy-values) - [Falsy values](#falsy-values) @@ -46,14 +46,10 @@ - [Getting minutes](#getting-minutes) - [Getting seconds](#getting-seconds) - [Getting time](#getting-time) -- [💻 Day 3: Exercises](#%f0%9f%92%bb-day-3-exercises) - - [1. Exercises: Data types Part](#1-exercises-data-types-part) - - [2. Exercises: Arithmetic Operators Part](#2-exercises-arithmetic-operators-part) - - [3. Exercises: Booleans Part](#3-exercises-booleans-part) - - [4. Exercises: Comparison Operators](#4-exercises-comparison-operators) - - [5. Exercises: Logical Operators](#5-exercises-logical-operators) - - [6 Ternary Operator](#6-ternary-operator) - - [7. Exercises: Date time Object](#7-exercises-date-time-object) + - [💻 Day 3: Exercises](#-day-3-exercises) + - [Exercises: Level 1](#exercises-level-1) + - [Exercises: Level 2](#exercises-level-2) + - [Exercises: Level 3](#exercises-level-3) # 📔 Day 3 @@ -68,8 +64,8 @@ let isLightOn = true let isRaining = false let isHungry = false let isMarried = true -let truValue = 4 > 3 // true -let falseValue = 3 < 4 // false +let truValue = 4 > 3 // true +let falseValue = 4 < 3 // false ``` We agreed that boolean values are either true or false. @@ -90,11 +86,11 @@ We agreed that boolean values are either true or false. - the boolean false - '', "", ``, empty string -It is good to remember those truthy values and falsy values. In later section, we will use them with conditions to make decision. +It is good to remember those truthy values and falsy values. In later section, we will use them with conditions to make decisions. ## Undefined -If we declare a variable and if we do not assign a value, the value will be undefined. In addition to this, if a function is not returning the value will be undefined. +If we declare a variable and if we do not assign a value, the value will be undefined. In addition to this, if a function is not returning the value, it will be undefined. ```js let firstName @@ -129,10 +125,10 @@ Arithmetic operators are mathematical operators. - Addition(+): a + b - Subtraction(-): a - b -- Multiplication(_): a _ b +- Multiplication(*): a * b - Division(/): a / b -- Modulus(%):a % b -- Exponential(**):a ** b +- Modulus(%): a % b +- Exponential(**): a ** b ```js let numOne = 4 @@ -146,23 +142,29 @@ let powerOf = numOne ** numTwo console.log(sum, diff, mult, div, remainder, powerOf) // 7,1,12,1.33,1, 64 -let PI = 3.14 -let radius = 100 // length in meter +``` -const gravity = 9.81 // in m/s2 -let mass = 72 // in Kilogram -const boilingPoint = 100 // temperature in oC, boiling point of water -const bodyTemp = 37 // body temperature in oC +```js +const PI = 3.14 +let radius = 100 // length in meter //Let us calculate area of a circle const areaOfCircle = PI * radius * radius console.log(areaOfCircle) // 314 m + +const gravity = 9.81 // in m/s2 +let mass = 72 // in Kilogram + // Let us calculate weight of an object const weight = mass * gravity console.log(weight) // 706.32 N(Newton) -//Concatenating string with numbers using string interpolation +const boilingPoint = 100 // temperature in oC, boiling point of water +const bodyTemp = 37 // body temperature in oC + + +// Concatenating string with numbers using string interpolation /* The boiling point of water is 100 oC. Human body temperature is 37 oC. @@ -191,14 +193,13 @@ console.log(3 != 2) // true, because 3 is not equal to 2 console.log(3 == '3') // true, compare only value console.log(3 === '3') // false, compare both value and data type console.log(3 !== '3') // true, compare both value and data type -console.log(3 !== '3') // true, compare both value and data type console.log(3 != 3) // false, compare only value console.log(3 !== 3) // false, compare both value and data type console.log(0 == false) // true, equivalent +console.log(0 === false) // false, not exactly the same console.log(0 == '') // true, equivalent console.log(0 == ' ') // true, equivalent console.log(0 === '') // false, not exactly the same -console.log(0 === false) // false, not exactly the same console.log(1 == true) // true, equivalent console.log(1 === true) // false, not exactly the same console.log(undefined == null) // true @@ -210,13 +211,13 @@ console.log(typeof NaN) // number console.log('mango'.length == 'avocado'.length) // false console.log('mango'.length != 'avocado'.length) // true console.log('mango'.length < 'avocado'.length) // true -console.log('milk'.length != 'meat'.length) // false console.log('milk'.length == 'meat'.length) // true +console.log('milk'.length != 'meat'.length) // false console.log('tomato'.length == 'potato'.length) // true console.log('python'.length > 'dragon'.length) // false ``` -Try to understand the above comparisons with some logic. Remember without any logic might be difficult. +Try to understand the above comparisons with some logic. Remembering without any logic might be difficult. JavaScript is some how a wired kind of programming language. JavaScript code run and give you a result but unless you are good at it may not be the desired result. As rule of thumb, if a value is not true with == it will not be equal with ===. Using === is safer than using ==. The following [link](https://dorey.github.io/JavaScript-Equality-Table/) has an exhaustive list of comparison of data types. @@ -225,30 +226,30 @@ As rule of thumb, if a value is not true with == it will not be equal with ===. The following symbols are the common logical operators: &&(ampersand) , ||(pipe) and !(negation). -&& gets true only if the two operands are true. -|| gets true either of the operand is true. -! negates true to false, false to true. +The && operator gets true only if the two operands are true. +The || operator gets true either of the operand is true. +The ! operator negates true to false and false to true. ```js -//&& ampersand operator example +// && ampersand operator example -const check = 4 > 3 && 10 > 5 // true and true -> true -const check = 4 > 3 && 10 < 5 // true and false -> false -const check = 4 < 3 && 10 < 5 // false and false -> false +const check = 4 > 3 && 10 > 5 // true && true -> true +const check = 4 > 3 && 10 < 5 // true && false -> false +const check = 4 < 3 && 10 < 5 // false && false -> false -//|| pipe or operator, example +// || pipe or operator, example -const check = 4 > 3 || 10 > 5 // true and true -> true -const check = 4 > 3 || 10 < 5 // true and false -> true -const check = 4 < 3 || 10 < 5 // false and false -> false +const check = 4 > 3 || 10 > 5 // true || true -> true +const check = 4 > 3 || 10 < 5 // true || false -> true +const check = 4 < 3 || 10 < 5 // false || false -> false //! Negation examples -let check = 4 > 3 // true -let check = !(4 > 3) // false +let check = 4 > 3 // true +let check = !(4 > 3) // false let isLightOn = true -let isLightOff = !isLightOn // false -let isMarried = !false // true +let isLightOff = !isLightOn // false +let isMarried = !false // true ``` ### Increment Operator @@ -259,16 +260,16 @@ In JavaScrip we use the increment operator to increase a value stored in a varia ```js let count = 0 -console.log(++count) // 1 -console.log(count) // 1 +console.log(++count) // 1 +console.log(count) // 1 ``` 1. Post-increment ```js let count = 0 -console.log(count++) // 0 -console.log(count) // 1 +console.log(count++) // 0 +console.log(count) // 1 ``` We use most of the time post-increment. At leas you should remember how to use post-increment operator. @@ -350,7 +351,7 @@ alert(message) alert('Welcome to 30DaysOfJavaScript') ``` -Do not use too much alert because it is destructing and annoying, use it just for to test. +Do not use too much alert because it is destructing and annoying, use it just to test. ### Window prompt() method @@ -368,8 +369,8 @@ console.log(number) ### Window confirm() method The confirm() method displays a dialog box with a specified message, along with an OK and a Cancel button. -A confirm box is often used to ask permission from a user to do something. Window confirm() takes an string as an argument. -Clicking the OK yields true value, clicking the Cancel button yields false value. +A confirm box is often used to ask permission from a user to execute something. Window confirm() takes a string as an argument. +Clicking the OK yields true value, whereas clicking the Cancel button yields false value. ```js const agree = confirm('Are you sure you like to delete? ') @@ -398,7 +399,7 @@ We have created a time object and we can access any date time information from t ### Getting full year -Let's extract or get the full from a time object. +Let's extract or get the full year from a time object. ```js const now = new Date() @@ -420,7 +421,7 @@ Let's extract or get the date of the month from a time object. ```js const now = new Date() -console.log(now.getDate()) // 4, because the day of the month is 4th, day(0-31) +console.log(now.getDate()) // 4, because the day of the month is 4th, day(1-31) ``` ### Getting day @@ -429,7 +430,8 @@ Let's extract or get the day of the week from a time object. ```js const now = new Date() -console.log(now.getDay()) // 6, because the day is Saturday which is the 5th day, +console.log(now.getDay()) // 6, because the day is Saturday which is the 7th day +// Sunday is 0, Monday is 1 and Saturday is 6 // Getting the weekday as a number (0-6) ``` @@ -476,6 +478,7 @@ console.log(now.getTime()) // 1578092201341, this is the number of seconds passe ```js const allSeconds = Date.now() // console.log(allSeconds) // 1578092201341, this is the number of seconds passed from January 1, 1970 to January 4, 2020 00:56:41 + const timeInSeconds = new Date().getTime() console.log(allSeconds == timeInSeconds) // true ``` @@ -490,21 +493,60 @@ const month = now.getMonth() + 1 // return month(0 - 11) const date = now.getDate() // return date (1 - 31) const hours = now.getHours() // return number (0 - 23) const minutes = now.getMinutes() // return number (0 -59) + console.log(`${date}/${month}/${year} ${hours}:${minutes}`) // 4/1/2020 0:56 ``` -🌕 You have boundless energy. You have just completed day 3 challenges and you are three steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle. +🌕 You have boundless energy. You have just completed day 3 challenges and you are three steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle. + +## 💻 Day 3: Exercises + +### Exercises: Level 1 -# 💻 Day 3: Exercises +1. Declare firstName, lastName, country, city, age, isMarried, year variable and assign value to it and use the typeof operator to check different data types. +2. Check if type of '10' is equal to 10 +3. Check if parseInt('9.8') is equal to 10 +4. Boolean value is either true or false. + 1. Write three JavaScript statement which provide truthy value. + 2. Write three JavaScript statement which provide falsy value. -## 1. Exercises: Data types Part +5. Figure out the result of the following comparison expression first without using console.log(). After you decide the result confirm it using console.log() + 1. 4 > 3 + 2. 4 >= 3 + 3. 4 < 3 + 4. 4 <= 3 + 5. 4 == 4 + 6. 4 === 4 + 7. 4 != 4 + 8. 4 !== 4 + 9. 4 != '4' + 10. 4 == '4' + 11. 4 === '4' + 12. Find the length of python and jargon and make a falsy comparison statement. + +6. Figure out the result of the following expressions first without using console.log(). After you decide the result confirm it by using console.log() + 1. 4 > 3 && 10 < 12 + 2. 4 > 3 && 10 > 12 + 3. 4 > 3 || 10 < 12 + 4. 4 > 3 || 10 > 12 + 5. !(4 > 3) + 6. !(4 < 3) + 7. !(false) + 8. !(4 > 3 && 10 < 12) + 9. !(4 > 3 && 10 > 12) + 10. !(4 === '4') + 11. There is no 'on' in both dragon and python -1. Declare firstName, lastName, country, city, age, isMarried, year variable and assign value to it -1. The JavaScript typeof operator uses to check different data types. Check the data type of each variables from question number 1. -1. Check if type of '10' is equal to 10 -1. Check if parseInt('9.8') is equal to 10 +7. Use the Date object to do the following activities + 1. What is the year today? + 2. What is the month today as a number? + 3. What is the date today? + 4. What is the day today as a number? + 5. What is the hours now? + 6. What is the minutes now? + 7. Find out the numbers of seconds elapsed from January 1, 1970 to now. -## 2. Exercises: Arithmetic Operators Part +### Exercises: Level 2 1. Write a script that prompt the user to enter base and height of the triangle and calculate an area of a triangle (area = 0.5 x b x h). @@ -531,75 +573,25 @@ console.log(`${date}/${month}/${year} ${hours}:${minutes}`) // 4/1/2020 0:56 1. Calculate the value of y (y = x^2 + 6x + 9). Try to use different x values and figure out at what x value y is 0. 1. Writ a script that prompt a user to enters hours and rate per hour. Calculate pay of the person? - ```sh - Enter hours: 40 - Enter rate per hour: 28 - Your weekly earning is 1120 - ``` - -1. Write a script that prompt the user to enter number of years. Calculate the number of seconds a person can live. Assume some one lives just hundred years - - ```sh - Enter number of yours you live: 100 - You lived 3153600000 seconds. - ``` - -## 3. Exercises: Booleans Part - -Boolean value is either true or false. - -1. Write three JavaScript statement which provide truthy value. -1. Write three JavaScript statement which provide falsy value. - -## 4. Exercises: Comparison Operators - -Figure out the result of the following comparison expression first without using console.log(). After you decide the result confirm it using console.log() - -1. 4 > 3 -1. 4 >= 3 -1. 4 < 3 -1. 4 <= 3 -1. 4 == 4 -1. 4 === 4 -1. 4 != 4 -1. 4 !== 4 -1. 4 != '4' -1. 4 == '4' -1. 4 === '4' - Find the length of python and jargon and make a falsy comparison statement. - -## 5. Exercises: Logical Operators - -1. Figure out the result of the following expressions first without using console.log(). After you decide the result confirm it by using console.log() - 1. 4 > 3 && 10 < 12 - 2. 4 > 3 && 10 > 12 - 3. 4 > 3 || 10 < 12 - 4. 4 > 3 || 10 > 12 - 5. !(4 > 3) - 6. !(4 < 3) - 7. !(false) - 8. !(4 > 3 && 10 < 12) - 9. !(4 > 3 && 10 > 12) - 10. !(4 === '4') -2. There is no 'on' in both dragon and python - -## 6 Ternary Operator + ```sh + Enter hours: 40 + Enter rate per hour: 28 + Your weekly earning is 1120 + ``` 1. If the length of your name is greater than 7 say, your name is long else say your name is short. 1. Compare your first name length and your family name length and you should get this output. -```js -let firstName = 'Asabeneh' -let lastName = 'Yetayeh' -``` + ```js + let firstName = 'Asabeneh' + let lastName = 'Yetayeh' + ``` -```sh -//Output -Your first name, Asabeneh is longer than your family name, Yetayeh -``` + ```sh + Your first name, Asabeneh is longer than your family name, Yetayeh + ``` 1. Declare two variables _myAge_ and _yourAge_ and assign them initial values and myAge and yourAge. - Output: ```js let myAge = 250 @@ -607,33 +599,35 @@ Your first name, Asabeneh is longer than your family name, Yetayeh ``` ```sh - //output I am 225 years older than you. ``` 1. Using prompt get the year the user was born and if the user is 18 or above allow the user to drive if not tell the user to wait a certain amount of years. -```sh -// if the age is 25 -You are 25. You are old enough to drive -// if the age is under 18 - You are 15. You will be allowed to drive after 3 years. -``` + ```sh + + Enter birth year: 1995 + You are 25. You are old enough to drive + + Enter birth year: 2005 + You are 15. You will be allowed to drive after 3 years. + ``` + +1. Write a script that prompt the user to enter number of years. Calculate the number of seconds a person can live. Assume some one lives just hundred years + + ```sh + Enter number of yours you live: 100 + You lived 3153600000 seconds. + ``` -## 7. Exercises: Date time Object +1. Create a human readable time format using the Date time object + 1. YYYY-MM-DD HH:mm + 2. DD-MM-YYYY HH:mm + 3. DD/MM/YYYY HH:mm -1. What is the year today? -1. What is the month today as a number? -1. What is the date today? -1. What is the day today as a number? -1. What is the hours now? -1. What is the minutes now? -1. Find out the numbers of seconds elapsed from January 1, 1970 to now. -1. Create a human readable time format - 1. YYY-MM-DD HH:mm:ss - 2. DD-MM-YYYY HH:mm:ss - 3. DD/MM/YYY HH:mm:ss +### Exercises: Level 3 -🎉 CONGRATULATIONS ! 🎉 +1. Create a human readable time format using the Date time object. The hour and the minute should be all the time two digits(7 hours should be 07 and 5 minutes should be 05 ) + 1. YYY-MM-DD HH:mm eg. 20120-01-02 07:05 -[<< Day 2](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/02_Day/02_day_data_types.md) | [Day 4 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/04_Day/04_day_conditionals.md) +[<< Day 2](../02_Day_Data_types/02_day_data_types.md) | [Day 4 >>](../04_Day_Conditionals/04_day_conditionals.md) diff --git a/03_Day/03_day_starter/index.html b/03_Day_Booleans_operators_date/03_day_starter/index.html similarity index 100% rename from 03_Day/03_day_starter/index.html rename to 03_Day_Booleans_operators_date/03_day_starter/index.html diff --git a/03_Day/03_day_starter/scripts/main.js b/03_Day_Booleans_operators_date/03_day_starter/scripts/main.js similarity index 100% rename from 03_Day/03_day_starter/scripts/main.js rename to 03_Day_Booleans_operators_date/03_day_starter/scripts/main.js diff --git a/04_Day/04_day_conditionals.md b/04_Day_Conditionals/04_day_conditionals.md similarity index 80% rename from 04_Day/04_day_conditionals.md rename to 04_Day_Conditionals/04_day_conditionals.md index 73f9a0a..f41cb10 100644 --- a/04_Day/04_day_conditionals.md +++ b/04_Day_Conditionals/04_day_conditionals.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Conditionals

@@ -13,24 +13,27 @@
-[<< Day 3](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/03_Day/03_booleans_operators_date.md) | [Day 5 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/05_Day/05_day_arrays.md) +[<< Day 3](../03_Day_Booleans_operators_date/03_booleans_operators_date.md) | [Day 5 >>](../05_Day_Arrays/05_day_arrays.md) ![Thirty Days Of JavaScript](../images/banners/day_1_4.png) -- [📔 Day 4](#%f0%9f%93%94-day-4) +- [📔 Day 4](#-day-4) - [Conditionals](#conditionals) - [if](#if) - [if else](#if-else) - [if else if else](#if-else-if-else) - [Switch](#switch) - [Ternary Operators](#ternary-operators) -- [💻 Exercise : Conditionals](#%f0%9f%92%bb-exercise--conditionals) + - [💻 Exercises](#-exercises) + - [Exercises: Level 1](#exercises-level-1) + - [Exercises: Level 2](#exercises-level-2) + - [Exercises: Level 3](#exercises-level-3) # 📔 Day 4 ## Conditionals -Conditional statements are used to decision based on different conditions. +Conditional statements are used to make decisions based on different conditions. By default , statements in JavaScript script executed sequentially from top to bottom. If the processing logic require so, the sequential flow of execution can be altered in two ways: - Conditional execution: a block of one or more statements will be executed if a certain expression is true @@ -46,7 +49,7 @@ Conditions can be implementing using the following ways: ### if -In JavaScript and other programming languages the key word _if_ use to check if a condition is true and to execute the block code. To create an if condition, we need _if_ keyword, condition inside a parenthesis and block of code inside a curly bracket({}). +In JavaScript and other programming languages the key word _if_ is used to check if a condition is true and to execute the block code. To create an if condition, we need _if_ keyword, condition inside a parenthesis and block of code inside a curly bracket({}). ```js // syntax @@ -65,6 +68,8 @@ if (num > 0) { // 3 is a positive number ``` +As you can see in the above condition, 3 is greater than 0 and it is a positive number. The condition was true and the block code was executed. However, if the condition is false, we do not see a result. + ```js let isRaining = true if (isRaining) { @@ -72,7 +77,7 @@ if (isRaining) { } ``` -As you can see in the above condition, 3 is greater than 0 and it is a positive number. The condition was true and the block code was executed. However, if the condition is false, we do not see a result. The same goes for the second condition, if isRaining is false the if block will not be executed and we do not see an output. In order to see the result of the falsy condition, we should have another block, which is going to be _else_. + The same goes for the second condition, if isRaining is false the if block will not be executed and we do not see an output. In order to see the result of the falsy condition, we should have another block, which is going to be _else_. ### if else @@ -127,7 +132,7 @@ The above condition is false, therefore the else block was executed. How about i ### if else if else -On our daily life, we make decision on daily basis. We make decision not by checking one or two conditions instead we make decisions based on multiple conditions. As similar to our daily life, programming is also full conditions. We use *else if* when we have multiple conditions. +On our daily life, we make decision on daily basis. We make decision not by checking one or two conditions instead we make decisions based on multiple conditions. As similar to our daily life, programming is also full of conditions. We use *else if* when we have multiple conditions. ```js // syntax @@ -238,6 +243,25 @@ switch (day) { ``` +// Examples to use conditions in the cases + +```js +let num = prompt('Enter number'); +switch (true) { + case num > 0: + console.log('Number is positive'); + break; + case num == 0: + console.log('Numbers is zero'); + break; + case num < 0: + console.log('Number is negative'); + break; + default: + console.log('Entered value was not a number'); +} +``` + ### Ternary Operators Another way to write conditionals is using ternary operators. We have covered this in other sections but we should also mention it here. @@ -251,7 +275,9 @@ isRaining 🌕 You are extraordinary and you have a remarkable potential. You have just completed day 4 challenges and you are four steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle. -# 💻 Exercise : Conditionals +## 💻 Exercises + +### Exercises: Level 1 1. Get user input using prompt(“Enter your age:”). If user is 18 or older , give feedback:You are old enough to drive but if not 18 give feedback to wait for the years he supposed to wait for. @@ -284,19 +310,6 @@ isRaining 4 is greater than 3 ``` -1. Write a code which give grade students according to theirs scores: - - 80-100, A - - 70-89, B - - 60-69, C - - 50-59, D - - 0 -49, F -1. Check if the season is Autumn, Winter, Spring or Summer. - If the user input is: - - September, October or November, the season is Autumn. - - December, January or February, the season is Winter. - - March, April or May, the season is Spring - - June, July or August, the season is Summer - 1. Even numbers are divisible by 2 and the remainder is zero. How do you check if a number is even or not using JavaScript? ```sh @@ -307,39 +320,54 @@ isRaining 9 is is an odd number. ``` +### Exercises: Level 2 + +1. Write a code which can give grade to students according to theirs scores: + - 80-100, A + - 70-89, B + - 60-69, C + - 50-59, D + - 0-49, F +1. Check if the season is Autumn, Winter, Spring or Summer. + If the user input is: + - September, October or November, the season is Autumn. + - December, January or February, the season is Winter. + - March, April or May, the season is Spring + - June, July or August, the season is Summer 1. Check if a day is weekend day or a working day. Your script will take day as an input. ```sh - What is the day is today? Saturday - Saturday is a weekend day. + What is the day today? Saturday + Saturday is a weekend. What is the day today? saturDaY - Saturday is a weekend day. + Saturday is a weekend. What is the day today? Friday - Friday is a work day. + Friday is a working day. What is the day today? FrIDAy - Friday is a work day. + Friday is a working day. ``` -1. Write a program which tells the number days in a month. +### Exercises: Level 3 + +1. Write a program which tells the number of days in a month. ```sh - Enter month: January + Enter a month: January January has 31 days. - Enter month: JANUARY + Enter a month: JANUARY January has 31 day - Enter month: February + Enter a month: February February has 28 days. - Enter month: FEbruary + Enter a month: FEbruary February has 28 days. ``` - 🎉 CONGRATULATIONS ! 🎉 -[<< Day 3](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/03_Day/03_booleans_operators_date.md) | [Day 5 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/05_Day/05_day_arrays.md) +[<< Day 3](../03_Day_Booleans_operators_date/03_booleans_operators_date.md) | [Day 5 >>](../05_Day_Arrays/05_day_arrays.md) diff --git a/04_Day/04_day_starter/index.html b/04_Day_Conditionals/04_day_starter/index.html similarity index 100% rename from 04_Day/04_day_starter/index.html rename to 04_Day_Conditionals/04_day_starter/index.html diff --git a/04_Day/04_day_starter/scripts/main.js b/04_Day_Conditionals/04_day_starter/scripts/main.js similarity index 100% rename from 04_Day/04_day_starter/scripts/main.js rename to 04_Day_Conditionals/04_day_starter/scripts/main.js diff --git a/05_Day/05_day_arrays.md b/05_Day_Arrays/05_day_arrays.md similarity index 86% rename from 05_Day/05_day_arrays.md rename to 05_Day_Arrays/05_day_arrays.md index 1fe70ed..3374c12 100644 --- a/05_Day/05_day_arrays.md +++ b/05_Day_Arrays/05_day_arrays.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Arrays

@@ -13,11 +13,11 @@
-[<< Day 4](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/04_Day/04_day_conditionals.md) | [Day 6 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/06_Day/06_day_loops.md) +[<< Day 4](../04_Day_Conditionals/04_day_Conditionals.md) | [Day 6 >>](../06_Day_Loops/06_day_loops.md) ![Day 5](../images/banners/day_1_5.png) -- [📔 Day 5](#%f0%9f%93%94-day-5) +- [📔 Day 5](#-day-5) - [Arrays](#arrays) - [How to create an empty array](#how-to-create-an-empty-array) - [How to create an array with values](#how-to-create-an-array-with-values) @@ -43,20 +43,23 @@ - [Reversing array order](#reversing-array-order) - [Sorting elements in array](#sorting-elements-in-array) - [Array of arrays](#array-of-arrays) - - [💻 Exercise](#%f0%9f%92%bb-exercise) + - [💻 Exercise](#-exercise) + - [Exercise: Level 1](#exercise-level-1) + - [Exercise: Level 2](#exercise-level-2) + - [Exercise: Level 3](#exercise-level-3) # 📔 Day 5 ## Arrays -In contrast to variables, an array can store _multiple values_. Each value in an array has an _index_, and each index has _a reference in a memory address_. Each value can be accessed by using their _indexes_. The index of an array starts from _zero_, and the last element is less by one from the length of the array. +In contrast to variables, an array can store _multiple values_. Each value in an array has an _index_, and each index has _a reference in a memory address_. Each value can be accessed by using their _indexes_. The index of an array starts from _zero_, and the index of the last element is less by one from the length of the array. An array is a collection of different data types which are ordered and changeable(modifiable). An array allows storing duplicate elements and different data types. An array can be empty, or it may have different data type values. ### How to create an empty array -In JavaScript, we can create an array in different ways. Let us different ways to create an array. -It is very common to use *const* instead of *let* to declare an array variable. If you ar using const it means you do not use that name again. +In JavaScript, we can create an array in different ways. Let us see different ways to create an array. +It is very common to use *const* instead of *let* to declare an array variable. If you ar using const it means you do not use that variable name again. - Using Array constructor @@ -163,7 +166,7 @@ console.log(words) ### Accessing array items using index -We access each element in an array using their index. An array index starts from 0. The picture below clearly shows the starting of the index. +We access each element in an array using their index. An array index starts from 0. The picture below clearly shows the index of each element in the array. ![arr index](../images/array_index.png) @@ -328,7 +331,7 @@ const eight0values = Array(8).fill(0) // it creates eight element values filled console.log(eight0values) // [0, 0, 0, 0, 0, 0, 0, 0] const four4values = Array(4).fill(4) // it creates 4 element values filled with '4' -console.log(four4values) // [4, 4, 4, 4, 4, 4, 4, 4] +console.log(four4values) // [4, 4, 4, 4] ``` #### Concatenating array using concat @@ -471,7 +474,7 @@ console.log(names.toString()) // Asabeneh,Mathias,Elias,Brook #### Joining array elements -join: It used to join the elements of the array, the argument passed in the join method will be joined in the array and return as a string. By default, it joins with a comma, but we can pass different string parameter which can be joined between the items. +join: It is used to join the elements of the array, the argument we passed in the join method will be joined in the array and return as a string. By default, it joins with a comma, but we can pass different string parameter which can be joined between the items. ```js const numbers = [1, 2, 3, 4, 5] @@ -529,8 +532,8 @@ Splice: It takes three parameters:Starting position, number of times to be remov ``` ```js - const numbers = [1, 2, 3, 4, 5]; - console.log(numbers.splice(3, 3, 6, 7, 8)) // -> [1, 2, 3, 6, 7, 8] //it removes two item and replace three items + const numbers = [1, 2, 3, 4, 5, 6]; + console.log(numbers.splice(3, 3, 7, 8, 9)) // -> [1, 2, 3, 7, 8, 9] //it removes three item and replace three items ``` #### Adding item to an array using push @@ -615,7 +618,7 @@ console.log(numbers) // [1, 2, 3, 4, 5] #### Sorting elements in array -sort: arrange array elements in ascending order. Sort takes a call back function, we will see how we use sort with call back function in the coming sections. +sort: arrange array elements in ascending order. Sort takes a call back function, we will see how we use sort with a call back function in the coming sections. ```js const webTechs = [ @@ -659,6 +662,8 @@ console.log(arrayOfArray[0]) // [1, 2, 3] ## 💻 Exercise +### Exercise: Level 1 + ```js const countries = [ 'Albania', @@ -686,30 +691,33 @@ const webTechs = [ ``` 1. Declare an _empty_ array; -1. Declare an array with more than 5 number of elements -1. Find the length of your array -1. Get the first item, the middle item and the last item of the array -1. Declare an array called _mixedDataTypes_,put different data types in your array and find length of the array. You are should size be greater than 5 -1. Declare an array variable name itCompanies and assign initial values Facebook, Google, Microsoft, Apple, IBM, Oracle and Amazon -1. Print the array using _console.log()_ -1. Print the number of companies in the array -1. Print the first company, middle and last company -1. Print out each company -1. Change each company name to uppercase one by one and print them out -1. Print the array like as a sentence: Facebook, Google, Microsoft, Apple, IBM,Oracle and Amazon are big IT companies. -1. Check if a certain company exists in the itCompanies array. If it exist return the company else return a company is _not found_ -1. Filter out companies which have more than one 'o' without the filter method -1. Sort the array using _sort()_ method -1. Reverse the array using _reverse()_ method -1. Slice out the first 3 companies from the array -1. Slice out the last 3 companies from the array -1. Slice out the middle IT company or companies from the array -1. Remove the first IT company from the array -1. Remove the middle IT company or companies from the array -1. Remove the last IT company from the array -1. Remove all IT companies -1. Create a separate countries.js file and store the countries array in to this file, create a separate file web_techs.js ans store the webTechs array in to this file. Access both file in main.js file -1. First remove all the functions and change the string to array and count the number of words in the array +2. Declare an array with more than 5 number of elements +3. Find the length of your array +4. Get the first item, the middle item and the last item of the array +5. Declare an array called _mixedDataTypes_, put different data types in the array and find the length of the array. The array size should be greater than 5 +6. Declare an array variable name itCompanies and assign initial values Facebook, Google, Microsoft, Apple, IBM, Oracle and Amazon +7. Print the array using _console.log()_ +8. Print the number of companies in the array +9. Print the first company, middle and last company +10. Print out each company +11. Change each company name to uppercase one by one and print them out +12. Print the array like as a sentence: Facebook, Google, Microsoft, Apple, IBM,Oracle and Amazon are big IT companies. +13. Check if a certain company exists in the itCompanies array. If it exist return the company else return a company is _not found_ +14. Filter out companies which have more than one 'o' without the filter method +15. Sort the array using _sort()_ method +16. Reverse the array using _reverse()_ method +17. Slice out the first 3 companies from the array +18. Slice out the last 3 companies from the array +19. Slice out the middle IT company or companies from the array +20. Remove the first IT company from the array +21. Remove the middle IT company or companies from the array +22. Remove the last IT company from the array +23. Remove all IT companies + +### Exercise: Level 2 + +1. Create a separate countries.js file and store the countries array in to this file, create a separate file web_techs.js and store the webTechs array in to this file. Access both file in main.js file +1. First remove all the punctuations and change the string to array and count the number of words in the array ```js let text = @@ -720,6 +728,7 @@ const webTechs = [ ```sh ["I", "love", "teaching", "and", "empowering", "people", "I", "teach", "HTML", "CSS", "JS", "React", "Python"] + 13 ``` @@ -729,10 +738,10 @@ const webTechs = [ const shoppingCart = ['Milk', 'Coffee', 'Tea', 'Honey'] ``` - - add 'Meat' in the beginning of your shopping cart if if it has not be already added - - add sugar at the end of you shopping cart if it has not been already added - - Remove 'Honey' if you are allergic to honey - - modify tea to 'Green Tea' + - add 'Meat' in the beginning of your shopping cart if it has not been already added + - add Sugar at the end of you shopping cart if it has not been already added + - remove 'Honey' if you are allergic to honey + - modify Tea to 'Green Tea' 1. In countries array check if 'Ethiopia' exists in the array if it exists print 'ETHIOPIA'. If it does not exist add to the countries list. 1. In the webTechs array check if Sass exists in the array and if it exists print 'Sass is a CSS preprocess'. If it does not exist add Sass to the array and print the array. 1. Concatenate the following two variables and store it in a fullStack variable. @@ -748,6 +757,8 @@ const webTechs = [ ["HTML", "CSS", "JS", "React", "Redux", "Node", "Express", "MongoDB"] ``` +### Exercise: Level 3 + 1. The following is an array of 10 students ages: ```js @@ -755,16 +766,14 @@ const webTechs = [ ``` - Sort the array and find the min and max age - - Find the min age and the max age - Find the median age(one middle item or two middle items divided by two) - Find the average age(all items divided by number of items) - Find the range of the ages(max minus min) - Compare the value of (min - average) and (max - average), use *abs()* method 1.Slice the first ten countries from the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) 1. Find the middle country(ies) in the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) -1. Find the middle country(ies) in the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) -1. Divide the countries array into two equal arrays if it is even. If countries array is not even , one more country for the first half. +2. Divide the countries array into two equal arrays if it is even. If countries array is not even , one more country for the first half. 🎉 CONGRATULATIONS ! 🎉 -[<< Day 4](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/04_Day/04_day_conditionals.md) | [Day 6 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/06_Day/06_day_loops.md) +[<< Day 4](../04_Day_Conditionals/04_day_Conditionals.md) | [Day 6 >>](../06_Day_Loops/06_day_loops.md) diff --git a/05_Day/05_day_starter/data/countries.js b/05_Day_Arrays/05_day_starter/data/countries.js similarity index 100% rename from 05_Day/05_day_starter/data/countries.js rename to 05_Day_Arrays/05_day_starter/data/countries.js diff --git a/05_Day/05_day_starter/index.html b/05_Day_Arrays/05_day_starter/index.html similarity index 100% rename from 05_Day/05_day_starter/index.html rename to 05_Day_Arrays/05_day_starter/index.html diff --git a/05_Day/05_day_starter/scripts/main.js b/05_Day_Arrays/05_day_starter/scripts/main.js similarity index 100% rename from 05_Day/05_day_starter/scripts/main.js rename to 05_Day_Arrays/05_day_starter/scripts/main.js diff --git a/06_Day/06_day_loops.md b/06_Day_Loops/06_day_loops.md similarity index 60% rename from 06_Day/06_day_loops.md rename to 06_Day_Loops/06_day_loops.md index 0a39f1d..f0809fb 100644 --- a/06_Day/06_day_loops.md +++ b/06_Day_Loops/06_day_loops.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Loops

@@ -13,11 +13,11 @@
-[<< Day 5](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/05_Day/05_day_arrays.md) | [Day 7 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/07_Day/07_day_functions.md) +[<< Day 5](../05_Day_Arrays/05_day_arrays.md) | [Day 7 >>](../07_Day_Functions/07_day_functions.md) ![Day 5](../images/banners/day_1_6.png) -- [📔 Day 6](#%f0%9f%93%94-day-6) +- [📔 Day 6](#-day-6) - [Loops](#loops) - [for Loop](#for-loop) - [while loop](#while-loop) @@ -25,20 +25,23 @@ - [for of loop](#for-of-loop) - [break](#break) - [continue](#continue) - - [💻 Exercises:Day 6](#%f0%9f%92%bb-exercisesday-6) + - [💻 Exercises:Day 6](#-exercisesday-6) + - [Exercises: Level 1](#exercises-level-1) + - [Exercises: Level 2](#exercises-level-2) + - [Exercises: Level 3](#exercises-level-3) # 📔 Day 6 ## Loops -Most of the activities we do in life are full of repetitions. Imagine if I ask you to print out from 0 to 100 using console.log(). To implement this simple task it may take you 2 to 5 minutes, such kind of tedious and repetitive task can be carried out using loop. +Most of the activities we do in life are full of repetitions. Imagine if I ask you to print out from 0 to 100 using console.log(). To implement this simple task it may take you 2 to 5 minutes, such kind of tedious and repetitive task can be carried out using loop. If you prefer watching the videos, you can checkout the [video tutorials](https://www.youtube.com/channel/UCM4xOopkYiPwJqyKsSqL9mw) -In programming languages to carry out repetitive task we use different kinds of loop. The following examples are the commonly used loops. +In programming languages to carry out repetitive task we use different kinds of loops. The following examples are the commonly used loops in JavaScript and other programming languages. ### for Loop ```js -//For loop structure +// For loop structure for(initialization, condition, increment/decrement){ // code goes here } @@ -48,6 +51,7 @@ for(initialization, condition, increment/decrement){ for(let i = 0; i <= 5; i++){ console.log(i) } + // 0 1 2 3 4 5 ``` @@ -55,7 +59,8 @@ for(let i = 0; i <= 5; i++){ for(let i = 5; i >= 0; i--){ console.log(i) } -// 5 4 3 2 1 0 + +// 5 4 3 2 1 0 ``` ```js @@ -79,7 +84,8 @@ const newArr = [] for(let i = 0; i < countries.length; i++){ newArr.push(countries[i].toUpperCase()) } -//["FINLAND", "SWEDEN", "DENMARK", "NORWAY", "ICELAND"] + +// ["FINLAND", "SWEDEN", "DENMARK", "NORWAY", "ICELAND"] ``` Adding all elements in the array @@ -127,6 +133,7 @@ while (i <= 5) { console.log(i) i++ } + // 0 1 2 3 4 5 ``` @@ -138,12 +145,13 @@ do { console.log(i) i++ } while (i <= 5) + // 0 1 2 3 4 5 ``` ### for of loop -We use for of loop for arrays. It is very hand way to iterate through an array if we are not interested in the index. +We use for of loop for arrays. It is very hand way to iterate through an array if we are not interested in the index of each element in the array. ```js for (const element of arr) { @@ -156,13 +164,17 @@ for (const element of arr) { const numbers = [1, 2, 3, 4, 5] for (const num of numbers) { - console.log(num) //1 2 3 4 5 + console.log(num) } +// 1 2 3 4 5 + for (const num of numbers) { - console.log(num * num) //1 4 9 16 25 + console.log(num * num) } +// 1 4 9 16 25 + // adding all the numbers in the array let sum = 0 for (const num of numbers) { @@ -170,8 +182,6 @@ for (const num of numbers) { } console.log(sum) // 15 - - const webTechs = [ 'HTML', 'CSS', @@ -183,11 +193,13 @@ const webTechs = [ ] for (const tech of webTechs) { - console.log(tech.toUpperCase()) // HTML CSS JAVASCRIPT REACT NODE MONGODB + console.log(tech.toUpperCase()) } +// HTML CSS JAVASCRIPT REACT NODE MONGODB + for (const tech of webTechs) { - console.log(tech[0]) //get only the first letter of each element, H C J R N M + console.log(tech[0]) // get only the first letter of each element, H C J R N M } ``` @@ -204,16 +216,42 @@ console.log(newArr) // ["FINLAND", "SWEDEN", "NORWAY", "DENMARK", "ICELAND"] ### break -content will be added soon +Break is used to interrupt a loop. + +```js +for(let i = 0; i <= 5; i++){ + if(i == 3){ + break + } + console.log(i) +} + +// 0 1 2 +``` + +The above code stops if 3 found in the iteration process. ### continue -content will added soon +We use the keyword *continue* to skip a certain iterations. + +```js +for(let i = 0; i <= 5; i++){ + if(i == 3){ + continue + } + console.log(i) +} + +// 0 1 2 4 5 +``` 🌕 You are so brave, you made it to this far. Now, you have gained the power to automate repetitive and tedious tasks. You have just completed day 6 challenges and you are 6 steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle. ## 💻 Exercises:Day 6 +### Exercises: Level 1 + ```js const countries = [ 'Albania', @@ -293,16 +331,16 @@ content will added soon 7. Use for loop to iterate from 0 to 100 and print only even numbers 8. Use for loop to iterate from 0 to 100 and print only odd numbers 9. Use for loop to iterate from 0 to 100 and print only prime numbers -10. Use for loop to iterate from 0 to 100 and print and print the sum of all numbers. +10. Use for loop to iterate from 0 to 100 and print the sum of all numbers. ```sh - The sum all numbers is 5050. + The sum of all numbers from 0 to 100 is 5050. ``` 11. Use for loop to iterate from 0 to 100 and print the sum of all evens and the sum of all odds. ```sh - The sum of all evens is 2550. And the sum of all odds is 2500. + The sum of all evens from 0 to 100 is 2550. And the sum of all odds from 0 to 100 is 2500. ``` 12. Use for loop to iterate from 0 to 100 and print the sum of all evens and the sum of all odds. Print sum of evens and sum of odds as array @@ -319,7 +357,9 @@ content will added soon 5j2khz ``` -16. Develop a small script which generate any number of characters random id: +### Exercises: Level 2 + +1. Develop a small script which generate any number of characters random id: ```sh fe3jo1gl124g @@ -329,31 +369,31 @@ content will added soon xkqci4utda1lmbelpkm03rba ``` -17. Write a script which generates a random hexadecimal number. +1. Write a script which generates a random hexadecimal number. ```sh '#ee33df' ``` -18. Write a script which generates a random rgb color number. +1. Write a script which generates a random rgb color number. ```sh rgb(240,180,80) ``` -19. Using the above countries array, create the following new array. +1. Using the above countries array, create the following new array. ```sh ["ALBANIA", "BOLIVIA", "CANADA", "DENMARK", "ETHIOPIA", "FINLAND", "GERMANY", "HUNGARY", "IRELAND", "JAPAN", "KENYA"] ``` -20. Using the above countries array, create an array for countries length'. +1. Using the above countries array, create an array for countries length'. ```sh [7, 7, 6, 7, 8, 7, 7, 7, 7, 5, 5] ``` -21. Use the countries array to create the following array of arrays: +1. Use the countries array to create the following array of arrays: ```sh [ @@ -371,42 +411,41 @@ content will added soon ] ``` -22. In above countries array, check if there is a country or countries containing the word 'land'. If there are countries containing 'land', print it as array. If there is no country containing the word 'land', print 'These are countries without land'. +2. In above countries array, check if there is a country or countries containing the word 'land'. If there are countries containing 'land', print it as array. If there is no country containing the word 'land', print 'All these countries are without land'. ```sh ['Finland', 'Iceland'] ``` -23. In above countries array, check if there a country or countries end with a substring 'ia'. If there are countries end with, print it as array. If there is no country containing the word 'land', print 'These are countries ends without ia'. +3. In above countries array, check if there is a country or countries end with a substring 'ia'. If there are countries end with, print it as array. If there is no country containing the word 'ai', print 'These are countries ends without ia'. ```sh ['Albania', 'Bolivia','Ethiopia'] ``` -24. Using the above countries array, find the country containing the biggest number of characters. +4. Using the above countries array, find the country containing the biggest number of characters. ```sh Ethiopia ``` -25. Using the above countries array, find the country containing only 5 characters. +5. Using the above countries array, find the country containing only 5 characters. ```sh ['Japan', 'Kenya'] ``` -26. Find the longest word in the webTechs array -27. Use the webTechs are to create the following array of arrays: +6. Find the longest word in the webTechs array +7. Use the webTechs array to create the following array of arrays: ```sh [["HTML", 4], ["CSS", 3],["JavaScript", 10],["React", 5],["Redux", 5],["Node", 4],["MongoDB", 7]] ``` -28. An application created using MongoDB, Express, React and Node is called a MERN stack. Create the acronym MERN by using the array mernStack - -29. Iterate through the array, ["HTML", "CSS", "JS", "React", "Redux", "Node", "Express", "MongoDB"] using a for loop or for of loop and print out the items. -30. This is a fruit array , ['banana', 'orange', 'mango', 'lemon'] reverse the order using loop without using a reverse method. -31. Print all the elements of array as shown below. +8. An application created using MongoDB, Express, React and Node is called a MERN stack app. Create the acronym MERN by using the array mernStack +9. Iterate through the array, ["HTML", "CSS", "JS", "React", "Redux", "Node", "Express", "MongoDB"] using a for loop or for of loop and print out the items. +10. This is a fruit array , ['banana', 'orange', 'mango', 'lemon'] reverse the order using loop without using a reverse method. +11. Print all the elements of array as shown below. ```js const fullStack = [ @@ -424,16 +463,19 @@ content will added soon EXPRESS MONGODB ``` -32. Copy countries array(Avoid mutation) -33. Arrays are mutable. Create a copy of array which does not modify the original. Sort the copied array and store in a variable sortedCountries -34. Sort the webTechs array and mernStack array -35. Extract all the countries contain the word 'land' from the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) and print it as array -36. Find the country containing the hightest number of characters in the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) -37. Extract all the countries contain the word 'land' from the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) and print it as array -38. Extract all the countries containing only four characters from the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) and print it as array -39. Extract all the countries containing two or more words from the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) and print it as array -40. Reverse the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) and capitalize each country and stored it as an array + +### Exercises: Level 3 + +1. Copy countries array(Avoid mutation) +1. Arrays are mutable. Create a copy of array which does not modify the original. Sort the copied array and store in a variable sortedCountries +1. Sort the webTechs array and mernStack array +1. Extract all the countries contain the word 'land' from the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) and print it as array +1. Find the country containing the hightest number of characters in the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) +1. Extract all the countries contain the word 'land' from the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) and print it as array +1. Extract all the countries containing only four characters from the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) and print it as array +1. Extract all the countries containing two or more words from the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) and print it as array +1. Reverse the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) and capitalize each country and stored it as an array 🎉 CONGRATULATIONS ! 🎉 -[<< Day 5](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/05_Day/05_day_arrays.md) | [Day 7 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/07_Day/07_day_functions.md) +[<< Day 5](../05_Day_Arrays/05_day_arrays.md) | [Day 7 >>](../07_Day_Functions/07_day_functions.md) diff --git a/06_Day/06_day_starter/data/countries.js b/06_Day_Loops/06_day_starter/data/countries.js similarity index 100% rename from 06_Day/06_day_starter/data/countries.js rename to 06_Day_Loops/06_day_starter/data/countries.js diff --git a/06_Day/06_day_starter/index.html b/06_Day_Loops/06_day_starter/index.html similarity index 100% rename from 06_Day/06_day_starter/index.html rename to 06_Day_Loops/06_day_starter/index.html diff --git a/06_Day/06_day_starter/scripts/main.js b/06_Day_Loops/06_day_starter/scripts/main.js similarity index 100% rename from 06_Day/06_day_starter/scripts/main.js rename to 06_Day_Loops/06_day_starter/scripts/main.js diff --git a/07_Day/07_day_functions.md b/07_Day_Functions/07_day_functions.md similarity index 72% rename from 07_Day/07_day_functions.md rename to 07_Day_Functions/07_day_functions.md index cb78a19..202ffad 100644 --- a/07_Day/07_day_functions.md +++ b/07_Day_Functions/07_day_functions.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Functions

@@ -13,11 +13,11 @@
-[<< Day 6](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/06_Day/06_day_loops.md) | [Day 8 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/08_Day/08_day_objects.md) +[<< Day 6](../06_Day_Loops/06_day_loops.md) | [Day 8 >>](../08_Day_Objects/08_day_objects.md) ![Thirty Days Of JavaScript](../images/banners/day_1_7.png) -- [📔 Day 7](#%f0%9f%93%94-day-7) +- [📔 Day 7](#-day-7) - [Functions](#functions) - [Function Declaration](#function-declaration) - [Function without a parameter and return](#function-without-a-parameter-and-return) @@ -34,7 +34,10 @@ - [Arrow Function](#arrow-function) - [Function with default parameters](#function-with-default-parameters) - [Function declaration versus Arrow function](#function-declaration-versus-arrow-function) - - [💻 Exercises](#%f0%9f%92%bb-exercises) + - [💻 Exercises](#-exercises) + - [Exercises: Level 1](#exercises-level-1) + - [Exercises: Level 2](#exercises-level-2) + - [Exercises: Level 3](#exercises-level-3) # 📔 Day 7 @@ -76,12 +79,13 @@ Function can be declared without a parameter. **Example:** ```js -// function without parameter, a function which square a number +// function without parameter, a function which make a number square function square() { let num = 2 let sq = num * num console.log(sq) } + square() // 4 // function without parameter @@ -92,18 +96,20 @@ function addTwoNumbers() { console.log(sum) } -addTwoNumbers() // function has to be called to be executed by it name + +addTwoNumbers() // a function has to be called by its name to be executed ``` ```js - function generateFullName (){ + function printFullName (){ let firstName = 'Asabeneh' let lastName = 'Yetayeh' let space = ' ' let fullName = firstName + space + lastName console.log(fullName) } - generateFullName() // calling a function + +printFullName() // calling a function ``` ### Function returning value @@ -111,14 +117,14 @@ addTwoNumbers() // function has to be called to be executed by it name Function can also return values, if a function does not return values the value of the function is undefined. Let us write the above functions with return. From now on, we return value to a function instead of printing it. ```js -function generateFullName (){ +function printFullName (){ let firstName = 'Asabeneh' let lastName = 'Yetayeh' let space = ' ' let fullName = firstName + space + lastName return fullName } -console.log(generateFullName()) +console.log(printFullName()) ``` ```js @@ -167,19 +173,20 @@ function functionName(parm1, parm2) { //code goes her } functionName(parm1, parm2) // during calling or invoking two arguments needed -// Function without parameter doesn't take input, so lets make a parameter with parameter +// Function without parameter doesn't take input, so lets make a function with parameters function sumTwoNumbers(numOne, numTwo) { let sum = numOne + numTwo console.log(sum) } sumTwoNumbers(10, 20) // calling functions // If a function doesn't return it doesn't store data, so it should return -function sumTwoNumbersAndReturn(numOne, numTwo) { + +function sumTwoNumbers(numOne, numTwo) { let sum = numOne + numTwo return sum } -console.log(sumTwoNumbersAndReturn(10, 20)) +console.log(sumTwoNumbers(10, 20)) function printFullName(firstName, lastName) { return `${firstName} ${lastName}` } @@ -200,7 +207,7 @@ functionName(parm1,parm2,parm3,...) // during calling or invoking three argument function sumArrayValues(arr) { let sum = 0; for (let i = 0; i < arr.length; i++) { - sum = sum + numbers[i]; + sum = sum + arr[i]; } return sum; } @@ -219,7 +226,7 @@ console.log(areaOfCircle(10)) ### Function with unlimited number of parameters -Sometimes we do not know how many arguments the user going to pass. Therefore, we should know how to write a function which can take unlimited number of arguments. The way we do it has a significant difference between a function declaration(regular function) and arrow function.Let us see examples both in function declaration and arrow function. +Sometimes we do not know how many arguments the user going to pass. Therefore, we should know how to write a function which can take unlimited number of arguments. The way we do it has a significant difference between a function declaration(regular function) and arrow function. Let us see examples both in function declaration and arrow function. #### Unlimited number of parameters in regular function @@ -301,15 +308,9 @@ const anonymousFun = function() { ### Expression Function -Expression functions are anonymous functions. After we create a function without a name and with assign it to a variable. To return a value from the function we should call the variable. Look at the example below. +Expression functions are anonymous functions. After we create a function without a name and we assign it to a variable. To return a value from the function we should call the variable. Look at the example below. ```js -//Declaration function -function square(n) { - return n * n -} - -console.log(square(2)) // -> 4 // Function expression const square = function(n) { @@ -339,7 +340,7 @@ console.log(squaredNum) Arrow function is an alternative to write a function, however function declaration and arrow function have some minor differences. -Arrow function uses arrow instead of the keyword function to declare a function. Let us see both function declaration and arrow function. +Arrow function uses arrow instead of the keyword *function* to declare a function. Let us see both function declaration and arrow function. ```js // This is how we write normal or declaration function @@ -354,9 +355,10 @@ const square = n => { return n * n } -console.log(square(2)) // -> 4 -// if we have only one line, it can be written as follows, explicit return -const square = n => n * n // -> 4 +console.log(square(2)) // -> 4 + +// if we have only one line in the code block, it can be written as follows, explicit return +const square = n => n * n // -> 4 ``` ```js @@ -500,10 +502,14 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra ### Function declaration versus Arrow function +It ill be covered in other time + 🌕 You are a rising star, now you knew function . Now, you are super charged with the power of functions. You have just completed day 7 challenges and you are 7 steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle. ## 💻 Exercises +### Exercises: Level 1 + 1. Declare a function _fullName_ and it print out your full name. 2. Declare a function _fullName_ and now it takes firstName, lastName as a parameter and it returns your full - name. 3. Declare a function _addNumbers_ and it takes two two parameters and it returns sum. @@ -533,9 +539,11 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra console.log(findMax(0, -10, -2)) 0 ``` + +### Exercises: Level 2 -16. Linear equation is calculated as follows: _ax + by + c = 0_. Write a function which calculates value of a linear equation, _solveLinEquation_. -17. Quadratic equation is calculated as follows: _ax2 + bx + c = 0_. Write a function which calculates value or values of a quadratic equation, _solveQuadEquation_. +1. Linear equation is calculated as follows: _ax + by + c = 0_. Write a function which calculates value of a linear equation, _solveLinEquation_. +1. Quadratic equation is calculated as follows: _ax2 + bx + c = 0_. Write a function which calculates value or values of a quadratic equation, _solveQuadEquation_. ```js console.log(solveQuadratic()) // {0} @@ -546,22 +554,22 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra console.log(solveQuadratic(1, -1, 0)) //{1, 0} ``` -18. Declare a function name _printArray_. It takes array as a parameter and it prints out each value of the array. -19. 11. Write a function name _showDateTime_ which shows time in this format: 08/01/2020 04:08 using the Date object. +1. Declare a function name _printArray_. It takes array as a parameter and it prints out each value of the array. +1. Write a function name _showDateTime_ which shows time in this format: 08/01/2020 04:08 using the Date object. ```sh showDateTime() 08/01/2020 04:08 ``` -20. Declare a function name _swapValues_. This function swaps value of x to y. +1. Declare a function name _swapValues_. This function swaps value of x to y. ```js swapValues(3, 4) // x => 4, y=>3 swapValues(4, 5) // x = 5, y = 4 ``` -21. Declare a function name _reverseArray_. It takes array as a parameter and it returns the reverse of the array (don't use method). +1. Declare a function name _reverseArray_. It takes array as a parameter and it returns the reverse of the array (don't use method). ```js console.log(reverseArray([1, 2, 3, 4, 5])) @@ -570,13 +578,13 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra //['C', 'B', 'A'] ``` -22. Declare a function name _capitalizeArray_. It takes array as a parameter and it returns the - capitalizedarray. -23. Declare a function name _addItem_. It takes an item parameter and it returns an array after adding the item -24. Declare a function name _removeItem_. It takes an index parameter and it returns an array after removing an item -25. Declare a function name _sumOfNumbers_. It takes a number parameter and it adds all the numbers in that range. -26. Declare a function name _sumOfOdds_. It takes a number parameter and it adds all the odd numbers in that - range. -27. Declare a function name _sumOfEven_. It takes a number parameter and it adds all the even numbers in that - range. -28. Declare a function name evensAndOdds . It takes a positive integer as parameter and it counts number of evens and odds in the number. +1. Declare a function name _capitalizeArray_. It takes array as a parameter and it returns the - capitalizedarray. +1. Declare a function name _addItem_. It takes an item parameter and it returns an array after adding the item +1. Declare a function name _removeItem_. It takes an index parameter and it returns an array after removing an item +1. Declare a function name _sumOfNumbers_. It takes a number parameter and it adds all the numbers in that range. +1. Declare a function name _sumOfOdds_. It takes a number parameter and it adds all the odd numbers in that - range. +1. Declare a function name _sumOfEven_. It takes a number parameter and it adds all the even numbers in that - range. +1. Declare a function name evensAndOdds . It takes a positive integer as parameter and it counts number of evens and odds in the number. ```sh evensAndOdds(100); @@ -584,30 +592,32 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra The number of evens are 51. ``` -29. Write a function which takes any number of arguments and return the sum of the arguments +1. Write a function which takes any number of arguments and return the sum of the arguments ```js sum(1, 2, 3) // -> 6 sum(1, 2, 3, 4) // -> 10 ``` -30. Writ a function which generates a _randomUserIp_. -31. Write a function which generates a _randomMacAddress_ -32. Declare a function name _randomHexaNumberGenerator_. When this function is called it generates a random hexadecimal number. The function return the hexadecimal number. +1. Writ a function which generates a _randomUserIp_. +1. Write a function which generates a _randomMacAddress_ +1. Declare a function name _randomHexaNumberGenerator_. When this function is called it generates a random hexadecimal number. The function return the hexadecimal number. ```sh console.log(randomHexaNumberGenerator()); '#ee33df' ``` -33. Declare a function name _userIdGenerator_. When this function is called it generates seven character id. The function return the id. +1. Declare a function name _userIdGenerator_. When this function is called it generates seven character id. The function return the id. ```sh console.log(userIdGenerator()); 41XTDbE ``` -34. Modify question number n . Declare a function name _userIdGeneratedByUser_. It doesn’t take any parameter but it takes two inputs using prompt(). One of the input is the number of characters and the second input is the number of ids which are supposed to be generated. +### Exercises: Level 3 + +1. Modify question number n . Declare a function name _userIdGeneratedByUser_. It doesn’t take any parameter but it takes two inputs using prompt(). One of the input is the number of characters and the second input is the number of ids which are supposed to be generated. ```sh userIdGeneratedByUser() @@ -626,18 +636,18 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra ' ``` -35. Write a function name _rgbColorGenerator_ and it generates rgb colors. +1. Write a function name _rgbColorGenerator_ and it generates rgb colors. ```sh rgbColorGenerator() rgb(125,244,255) ``` -36. Write a function **_arrayOfHexaColors_** which return any number of hexadecimal colors in an array. -37. Write a function **_arrayOfRgbColors_** which return any number of RGB colors in an array. -38. Write a function **_convertHexaToRgb_** which converts hexa color to rgb and it returns an rgb color. -39. Write a function **_convertRgbToHexa_** which converts rgb to hexa color and it returns an hexa color. -40. Write a function **_generateColors_** which can generate any number of hexa or rgb colors. +1. Write a function **_arrayOfHexaColors_** which return any number of hexadecimal colors in an array. +1. Write a function **_arrayOfRgbColors_** which return any number of RGB colors in an array. +1. Write a function **_convertHexaToRgb_** which converts hexa color to rgb and it returns an rgb color. +1. Write a function **_convertRgbToHexa_** which converts rgb to hexa color and it returns an hexa color. +1. Write a function **_generateColors_** which can generate any number of hexa or rgb colors. ```js console.log(generateColors('hexa', 3)) // ['#a3e12f', '#03ed55', '#eb3d2b'] @@ -646,35 +656,51 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra console.log(generateColors('rgb', 1)) // 'rgb(33,79, 176)' ``` -41. Call your function _shuffleArray_, it takes an array as a parameter and it returns a shuffled array -42. Call your function _factorial_, it takes a whole number as a parameter and it return a factorial of the number -43. Call your function _isEmpty_, it takes a parameter and it checks if it is empty or not -44. Call your function _sum_, it takes any number of arguments and it returns the sum. -45. Write a function called _sumOfArrayItems_, it takes an array parameter and return the sum of all the items. Check if all the array items are number types. If not give return reasonable feedback. -46. Write a function called _average_, it takes an array parameter and returns the average of the items. Check if all the array items are number types. If not give return reasonable feedback. -47. Write a function called _modifyArray_ takes array as parameter and modifies the fifth item of the array and return the array. If the array length is less than five it return 'item not found'. +1. Call your function _shuffleArray_, it takes an array as a parameter and it returns a shuffled array +1. Call your function _factorial_, it takes a whole number as a parameter and it return a factorial of the number +1. Call your function _isEmpty_, it takes a parameter and it checks if it is empty or not +1. Call your function _sum_, it takes any number of arguments and it returns the sum. +1. Write a function called _sumOfArrayItems_, it takes an array parameter and return the sum of all the items. Check if all the array items are number types. If not give return reasonable feedback. +1. Write a function called _average_, it takes an array parameter and returns the average of the items. Check if all the array items are number types. If not give return reasonable feedback. +1. Write a function called _modifyArray_ takes array as parameter and modifies the fifth item of the array and return the array. If the array length is less than five it return 'item not found'. ```js console.log(modifyArray(['Avocado', 'Tomato', 'Potato','Mango', 'Lemon','Carrot']); - // →['Avocado', 'Tomato', 'Potato','Mango', 'LEMON', 'Carrot'] + ``` + + ```sh + ['Avocado', 'Tomato', 'Potato','Mango', 'LEMON', 'Carrot'] + ``` + + ```js console.log(modifyArray(['Google', 'Facebook','Apple', 'Amazon','Microsoft', 'IBM']); - // →['Google', 'Facebook','Apple', 'Amazon','MICROSOFT', 'IBM'] + ``` + + ```sh + ['Google', 'Facebook','Apple', 'Amazon','MICROSOFT', 'IBM'] + ``` + + ```js console.log(modifyArray(['Google', 'Facebook','Apple', 'Amazon']); - // →'Not Found' ``` -48. Write a function called _isPrime_, which checks if a number is prime number. -49. Write a functions which checks if all items are unique in the array. -50. Write a function which checks if all the items of the array are the same data type. -51. JavaScript variable name does not support special characters or symbols except \$ or \_. Write a function **\*isValidVariable** which check if a variable is valid or invalid variable. -52. Write a function which returns array of seven random numbers in a range of 0-9. All the numbers must be unique. + ```sh + 'Not Found' + ``` + +1. Write a function called _isPrime_, which checks if a number is prime number. +1. Write a functions which checks if all items are unique in the array. +1. Write a function which checks if all the items of the array are the same data type. +1. JavaScript variable name does not support special characters or symbols except \$ or \_. Write a function **isValidVariable** which check if a variable is valid or invalid variable. +1. Write a function which returns array of seven random numbers in a range of 0-9. All the numbers must be unique. ```js - sevenRandomNumbers()[(1, 4, 5, 7, 9, 8, 0)] + sevenRandomNumbers() + [(1, 4, 5, 7, 9, 8, 0)] ``` -53. Write a function called reverseCountries, it takes countries array and first it copy the array and returns the reverse of the original array +1. Write a function called reverseCountries, it takes countries array and first it copy the array and returns the reverse of the original array 🎉 CONGRATULATIONS ! 🎉 -[<< Day 6](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/06_Day/06_day_loops.md) | [Day 8 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/08_Day/08_day_objects.md) +[<< Day 6](../06_Day_Loops/06_day_loops.md) | [Day 8 >>](../08_Day_Objects/08_day_objects.md) \ No newline at end of file diff --git a/07_Day/07_day_starter/data/countries.js b/07_Day_Functions/07_day_starter/data/countries.js similarity index 100% rename from 07_Day/07_day_starter/data/countries.js rename to 07_Day_Functions/07_day_starter/data/countries.js diff --git a/07_Day/07_day_starter/index.html b/07_Day_Functions/07_day_starter/index.html similarity index 100% rename from 07_Day/07_day_starter/index.html rename to 07_Day_Functions/07_day_starter/index.html diff --git a/07_Day/07_day_starter/scripts/main.js b/07_Day_Functions/07_day_starter/scripts/main.js similarity index 100% rename from 07_Day/07_day_starter/scripts/main.js rename to 07_Day_Functions/07_day_starter/scripts/main.js diff --git a/08_Day/08_day_objects.md b/08_Day_Objects/08_day_objects.md similarity index 75% rename from 08_Day/08_day_objects.md rename to 08_Day_Objects/08_day_objects.md index 8b03364..de91f2f 100644 --- a/08_Day/08_day_objects.md +++ b/08_Day_Objects/08_day_objects.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Objects

@@ -13,16 +13,16 @@
-[<< Day 7](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/07_Day/07_day_functions.md) | [Day 9 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/09_Day/09_day_higher_order_functions.md) +[<< Day 7](../07_Day_Functions/07_day_functions.md) | [Day 9 >>](../09_Day_Higher_order_functions/09_day_higher_order_functions.md) ![Thirty Days Of JavaScript](../images/banners/day_1_8.png) -- [📔 Day 8](#%f0%9f%93%94-day-8) +- [📔 Day 8](#-day-8) - [Scope](#scope) - [Window Scope](#window-scope) - [Global scope](#global-scope) - [Local scope](#local-scope) - - [📔 Object](#%f0%9f%93%94-object) + - [📔 Object](#-object) - [Creating an empty object](#creating-an-empty-object) - [Creating an objecting with values](#creating-an-objecting-with-values) - [Getting values from an object](#getting-values-from-an-object) @@ -33,7 +33,10 @@ - [Getting object values using Object.values()](#getting-object-values-using-objectvalues) - [Getting object keys and values using Object.entries()](#getting-object-keys-and-values-using-objectentries) - [Checking properties using hasOwnProperty()](#checking-properties-using-hasownproperty) - - [💻 Exercises](#%f0%9f%92%bb-exercises) + - [💻 Exercises](#-exercises) + - [Exercises: Level 1](#exercises-level-1) + - [Exercises: Level 2](#exercises-level-2) + - [Exercises: Level 3](#exercises-level-3) # 📔 Day 8 @@ -70,7 +73,7 @@ console.log(a, b) // accessible ### Global scope -A globally declared variable can be access every where in the same file. But the term global is relative. It can be global to the file or it can be global relative to some block of codes. +A globally declared variable can be accessed every where in the same file. But the term global is relative. It can be global to the file or it can be global relative to some block of codes. ```js //scope.js @@ -91,7 +94,7 @@ console.log(a, b) // JavaScript 10, accessible ### Local scope -A local declared variable can be access only certain block code. +A variable declared as local can be accessed only in certain block code. ```js //scope.js @@ -115,7 +118,7 @@ letsLearnScope() console.log(a, b) // JavaScript 10, accessible ``` -Now, you have an understanding of scope. A variable declared with *var* only scoped to function but variable declared with *let* or *const* is block scope(function block, if block, loop etc) +Now, you have an understanding of scope. A variable declared with *var* only scoped to function but variable declared with *let* or *const* is block scope(function block, if block, loop etc). Block in JavaScript is a code in between two curly brackets ({}). ```js //scope.js @@ -139,7 +142,7 @@ console.log(i) ``` -In ES6 and above there is *let* and *const*, so you will suffer from the sneakiness of *var*. When we use *let* our variable is block scope and it will not infect other parts of our code. +In ES6 and above there is *let* and *const*, so you will not suffer from the sneakiness of *var*. When we use *let* our variable is block scoped and it will not infect other parts of our code. ```js //scope.js @@ -164,12 +167,12 @@ for(let i = 0; i < 3; i++){ ``` -The scope *let* and *const* is the same. The difference is only reassigning. We can not change or reassign the value of const variable. I would strongly suggest you to use *let* and *const*, by using *let* and *const* you will writ clean code and avoid hard to debug mistakes. As a rule of thumb, you can use *let* for any value which change, *const* for any constant value, array, object, arrow function and function expression. +The scope *let* and *const* is the same. The difference is only reassigning. We can not change or reassign the value of const variable. I would strongly suggest you to use *let* and *const*, by using *let* and *const* you will writ clean code and avoid hard to debug mistakes. As a rule of thumb, you can use *let* for any value which change, *const* for any constant value, and for array, object, arrow function and function expression. ## 📔 Object -Everything can be an object and objects do have properties and properties have values, so an object is key value pair. The order of the key is not reserved, or there is no order. -Creating an object literal. To create an object literal, we use two curly brackets. +Everything can be an object and objects do have properties and properties have values, so an object is a key value pair. The order of the key is not reserved, or there is no order. +To create an object literal, we use two curly brackets. ### Creating an empty object @@ -183,7 +186,7 @@ const person = {} Now, the person object has firstName, lastName, age, location, skills and isMarried properties. The value of properties or keys could be a string, number, boolean, an object, null, undefined or a function. -Let us see some examples of object. Each key has a value in object. +Let us see some examples of object. Each key has a value in the object. ```js const rectangle = { @@ -365,7 +368,7 @@ const person = { city: 'Helsinki' }, getPersonInfo: function() { - return `I am ${this.firstName} and I live in ${city}, ${this.country}. I am ${this.age}.` + return `I am ${this.firstName} and I live in ${this.city}, ${this.country}. I am ${this.age}.` } } @@ -414,16 +417,21 @@ console.log(copyPerson.hasOwnProperty('name')) console.log(copyPerson.hasOwnProperty('score')) ``` -🌕 You are astonishing. Now, you are super charged with the power of objects. You have just completed day 7 challenges and you are 7 steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle. +🌕 You are astonishing. Now, you are super charged with the power of objects. You have just completed day 8 challenges and you are 8 steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle. ## 💻 Exercises +### Exercises: Level 1 + 1. Create an empty object called dog 1. Print the the dog object on the console 1. Add name, legs, color, age and bark properties for the dog object. The bark property is a method which return _woof woof_ 1. Get name, legs, color, age and bark value from the dog object 1. Set new properties the dog object: breed, getDogInfo -1. Create an object literal called _personAccount_. It has _firstName, lastName, incomes, expenses_ properties and it has _totalIncome, totalExpense, accountInfo,addIncome, addExpense_ and _accountBalance_ methods. Incomes is a set of incomes and its description and expenses is a set of incomes and its description. + +### Exercises: Level 2 + +1. Find the person who has many skills in the users object. 1. Count logged in users,count users having greater than equal to 50 points from the following object. ````js @@ -479,15 +487,103 @@ console.log(copyPerson.hasOwnProperty('score')) } }``` - ```` - 1. Find people who are MERN stack developer from the users object 1. Set your name in the users object without modifying the original users object 1. Get all keys or properties of users object 1. Get all the values of users object 1. Use the countries object to print a country name, capital, populations and languages. +### Exercises: Level 3 + +1. Create an object literal called _personAccount_. It has _firstName, lastName, incomes, expenses_ properties and it has _totalIncome, totalExpense, accountInfo,addIncome, addExpense_ and _accountBalance_ methods. Incomes is a set of incomes and its description and expenses is a set of incomes and its description. +2. **** Questions:2, 3 and 4 are based on the following two arrays:users and products () + + ```js + const users = [ + { + _id: 'ab12ex', + username: 'Alex', + email: 'alex@alex.com', + password: '123123', + createdAt:'08/01/2020 9:00 AM', + isLoggedIn: false + }, + { + _id: 'fg12cy', + username: 'Asab', + email: 'asab@asab.com', + password: '123456', + createdAt:'08/01/2020 9:30 AM', + isLoggedIn: true + }, + { + _id: 'zwf8md', + username: 'Brook', + email: 'brook@brook.com', + password: '123111', + createdAt:'08/01/2020 9:45 AM', + isLoggedIn: true + }, + { + _id: 'eefamr', + username: 'Martha', + email: 'martha@martha.com', + password: '123222', + createdAt:'08/01/2020 9:50 AM', + isLoggedIn: false + }, + { + _id: 'ghderc', + username: 'Thomas', + email: 'thomas@thomas.com', + password: '123333', + createdAt:'08/01/2020 10:00 AM', + isLoggedIn: false + } + ]; + + const products = [ + { + _id: 'eedfcf', + name: 'mobile phone', + description: 'Huawei Honor', + price: 200, + ratings: [ + { userId: 'fg12cy', rate: 5 }, + { userId: 'zwf8md', rate: 4.5 } + ], + likes: [] + }, + { + _id: 'aegfal', + name: 'Laptop', + description: 'MacPro: System Darwin', + price: 2500, + ratings: [], + likes: ['fg12cy'] + }, + { + _id: 'hedfcg', + name: 'TV', + description: 'Smart TV:Procaster', + price: 400, + ratings: [{ userId: 'fg12cy', rate: 5 }], + likes: ['fg12cy'] + } + ] + ``` + + Imagine you are getting the above users collection from a MongoDB database. + a. Create a function called signUp which allows user to add to the collection. If user exists, inform the user that he has already an account. + b. Create a function called signIn which allows user to sign in to the application + +3. The products array has three elements and each of them has six properties. + a. Create a function called rateProduct which rates the product + b. Create a function called averageRating which calculate the average rating of a product + +4. Create a function called likeProduct. This function will helps to like to the product if it is not liked and remove like if it was liked. + 🎉 CONGRATULATIONS ! 🎉 -[<< Day 7](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/07_Day/07_day_functions.md) | [Day 9 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/09_Day/09_day_higher_order_functions.md) +[<< Day 7](../07_Day_Functions/07_day_functions.md) | [Day 9 >>](../09_Day_Higher_order_functions/09_day_higher_order_functions.md) diff --git a/08_Day/08_day_starter/data/countries_data.js b/08_Day_Objects/08_day_starter/data/countries_data.js similarity index 100% rename from 08_Day/08_day_starter/data/countries_data.js rename to 08_Day_Objects/08_day_starter/data/countries_data.js diff --git a/08_Day/08_day_starter/index.html b/08_Day_Objects/08_day_starter/index.html similarity index 100% rename from 08_Day/08_day_starter/index.html rename to 08_Day_Objects/08_day_starter/index.html diff --git a/08_Day/08_day_starter/scripts/main.js b/08_Day_Objects/08_day_starter/scripts/main.js similarity index 100% rename from 08_Day/08_day_starter/scripts/main.js rename to 08_Day_Objects/08_day_starter/scripts/main.js diff --git a/09_Day/09_day_higher_order_functions.md b/09_Day_Higher_order_functions/09_day_higher_order_functions.md similarity index 78% rename from 09_Day/09_day_higher_order_functions.md rename to 09_Day_Higher_order_functions/09_day_higher_order_functions.md index 7d5728a..12faddb 100644 --- a/09_Day/09_day_higher_order_functions.md +++ b/09_Day_Higher_order_functions/09_day_higher_order_functions.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Higher Order Functions

@@ -13,7 +13,7 @@
-[<< Day 8](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/08_Day/08_day_objects.md) | [Day 10 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/10_Day/10_day_Set_and_Map.md) +[<< Day 8](../08_Day_Objects/08_day_objects.md) | [Day 10 >>](../10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md) ![Day 5](../images/banners/day_1_9.png) @@ -37,7 +37,10 @@ - [Sorting string values](#sorting-string-values) - [Sorting Numeric values](#sorting-numeric-values) - [Sorting Object Arrays](#sorting-object-arrays) - - [💻 Exercises](#%f0%9f%92%bb-exercises) + - [💻 Exercises](#-exercises) + - [Exercises: Level 1](#exercises-level-1) + - [Exercises: Level 2](#exercises-level-2) + - [Exercises: Level 3](#exercises-level-3) # Day 9 @@ -553,6 +556,8 @@ console.log(users) // sorted ascending ## 💻 Exercises +### Exercises: Level 1 + ```js const countries = ['Finland', 'Sweden', 'Denmark', 'Norway', 'IceLand'] const names = ['Asabeneh', 'Mathias', 'Elias', 'Brook'] @@ -582,8 +587,6 @@ const products = [ 13. Use **_filter_** to filter out countries containing six letters and more in the country array. 14. Use **_filter_** to filter out country start with 'E'; 15. Use **_filter_** to filter out only prices with values. -16. Find the total price of products by chaining two or more array iterators(eg. arr.map(callback).filter(callback).reduce(callback)) -17. Find the sum of price of products using only reduce reduce(callback)) 18. Declare a function called getStringLists which takes an array as a parameter and then returns an array only with string items. 19. Use **_reduce_** to sum all the numbers in the numbers array. 20. Use **_reduce_** to concatenate all the countries and to produce this sentence: **_Estonia, Finland, Sweden, Denmark, Norway, and IceLand are north European countries_** @@ -595,13 +598,21 @@ const products = [ 26. Use **_findIndex_** to find the position of the first country containing only six letters in the countries array 27. Use **_findIndex_** to find the position of **_Norway_** if it doesn't exist in the array you will get -1. 28. Use **_findIndex_** to find the position of **_Russia_** if it doesn't exist in the array you will get -1. -29. Declare a function called **_categorizeCountries_** which returns an array of countries which have some common pattern(you find the countries array in this repository as countries.js(eg 'land', 'ia', 'island','stan')). -30. Create a function which return an array of objects, which is the letter and the number of times the letter use to start with a name of a country. -31. Declare a **_getFirstTenCountries_** function and return an array of ten countries. Use different functional programming to work on the countries.js array -32. Declare a **_getLastTenCountries_** function which which returns the last ten countries in the countries array. -33. Find out which _letter_ is used many _times_ as initial for a country name from the countries array (eg. Finland, Fiji, France etc) -34. Use the countries information, in the data folder. Sort countries by name, by capital, by population -35. \*\*\* Find the 10 most spoken languages: + +### Exercises: Level 2 + +1. Find the total price of products by chaining two or more array iterators(eg. arr.map(callback).filter(callback).reduce(callback)) +1. Find the sum of price of products using only reduce reduce(callback)) +1. Declare a function called **_categorizeCountries_** which returns an array of countries which have some common pattern(you find the countries array in this repository as countries.js(eg 'land', 'ia', 'island','stan')). +1. Create a function which return an array of objects, which is the letter and the number of times the letter use to start with a name of a country. +1. Declare a **_getFirstTenCountries_** function and return an array of ten countries. Use different functional programming to work on the countries.js array +1. Declare a **_getLastTenCountries_** function which which returns the last ten countries in the countries array. +1. Find out which _letter_ is used many _times_ as initial for a country name from the countries array (eg. Finland, Fiji, France etc) + +### Exercises: Level 3 + +1. Use the countries information, in the data folder. Sort countries by name, by capital, by population +1. \*\*\* Find the 10 most spoken languages: ````js // Your output should look like this @@ -628,67 +639,66 @@ const products = [ ```` -36. \*\*\* Use countries_data.js file create a function which create the ten most populated countries - -````js -console.log(mostPopulatedCountries(countries, 10)) - -[ -{country: 'China', population: 1377422166}, -{country: 'India', population: 1295210000}, -{country: 'United States of America', population: 323947000}, -{country: 'Indonesia', population: 258705000}, -{country: 'Brazil', population: 206135893}, -{country: 'Pakistan', population: 194125062}, -{country: 'Nigeria', population: 186988000}, -{country: 'Bangladesh', population: 161006790}, -{country: 'Russian Federation', population: 146599183}, -{country: 'Japan', population: 126960000} -] - -console.log(mostPopulatedCountries(countries, 3)) -[ -{country: 'China', population: 1377422166}, -{country: 'India', population: 1295210000}, -{country: 'United States of America', population: 323947000} -]``` - -```` - -37. \*\*\* Try to develop a program which calculate measure of central tendency of a sample(mean, median, mode) and measure of variability(range, variance, standard deviation). In addition to those measures find the min, max, count, percentile, and frequency distribution of the sample. You can create an object called statistics and create all the functions which do statistical calculations as method for the statistics object. Check the output below. +1. \*\*\* Use countries_data.js file create a function which create the ten most populated countries -```js -const ages = [31, 26, 34, 37, 27, 26, 32, 32, 26, 27, 27, 24, 32, 33, 27, 25, 26, 38, 37, 31, 34, 24, 33, 29, 26] - -console.log('Count:', statistics.count()) // 25 -console.log('Sum: ', statistics.sum()) // 744 -console.log('Min: ', statistics.min()) // 24 -console.log('Max: ', statistics.max()) // 38 -console.log('Range: ', statistics.range() // 14 -console.log('Mean: ', statistics.mean()) // 30 -console.log('Median: ',statistics.median()) // 29 -console.log('Mode: ', statistics.mode()) // {'mode': 26, 'count': 5} -console.log('Variance: ',statistics.var()) // 17.5 -console.log('Standard Deviation: ', statistics.std()) // 4.2 -console.log('Variance: ',statistics.var()) // 17.5 -console.log('Frequency Distribution: ',statistics.freqDist()) # [(20.0, 26), (16.0, 27), (12.0, 32), (8.0, 37), (8.0, 34), (8.0, 33), (8.0, 31), (8.0, 24), (4.0, 38), (4.0, 29), (4.0, 25)] -``` + ````js + console.log(mostPopulatedCountries(countries, 10)) -```sh -console.log(statistics.describe()) -Count: 25 -Sum: 744 -Min: 24 -Max: 38 -Range: 14 -Mean: 30 -Median: 29 -Mode: (26, 5) -Variance: 17.5 -Standard Deviation: 4.2 -Frequency Distribution: [(20.0, 26), (16.0, 27), (12.0, 32), (8.0, 37), (8.0, 34), (8.0, 33), (8.0, 31), (8.0, 24), (4.0, 38), (4.0, 29), (4.0, 25)] -``` + [ + {country: 'China', population: 1377422166}, + {country: 'India', population: 1295210000}, + {country: 'United States of America', population: 323947000}, + {country: 'Indonesia', population: 258705000}, + {country: 'Brazil', population: 206135893}, + {country: 'Pakistan', population: 194125062}, + {country: 'Nigeria', population: 186988000}, + {country: 'Bangladesh', population: 161006790}, + {country: 'Russian Federation', population: 146599183}, + {country: 'Japan', population: 126960000} + ] + + console.log(mostPopulatedCountries(countries, 3)) + [ + {country: 'China', population: 1377422166}, + {country: 'India', population: 1295210000}, + {country: 'United States of America', population: 323947000} + ] + ``` + +1. \*\*\* Try to develop a program which calculate measure of central tendency of a sample(mean, median, mode) and measure of variability(range, variance, standard deviation). In addition to those measures find the min, max, count, percentile, and frequency distribution of the sample. You can create an object called statistics and create all the functions which do statistical calculations as method for the statistics object. Check the output below. + + ```js + const ages = [31, 26, 34, 37, 27, 26, 32, 32, 26, 27, 27, 24, 32, 33, 27, 25, 26, 38, 37, 31, 34, 24, 33, 29, 26] + + console.log('Count:', statistics.count()) // 25 + console.log('Sum: ', statistics.sum()) // 744 + console.log('Min: ', statistics.min()) // 24 + console.log('Max: ', statistics.max()) // 38 + console.log('Range: ', statistics.range() // 14 + console.log('Mean: ', statistics.mean()) // 30 + console.log('Median: ',statistics.median()) // 29 + console.log('Mode: ', statistics.mode()) // {'mode': 26, 'count': 5} + console.log('Variance: ',statistics.var()) // 17.5 + console.log('Standard Deviation: ', statistics.std()) // 4.2 + console.log('Variance: ',statistics.var()) // 17.5 + console.log('Frequency Distribution: ',statistics.freqDist()) # [(20.0, 26), (16.0, 27), (12.0, 32), (8.0, 37), (8.0, 34), (8.0, 33), (8.0, 31), (8.0, 24), (4.0, 38), (4.0, 29), (4.0, 25)] + ``` + + ```sh + console.log(statistics.describe()) + Count: 25 + Sum: 744 + Min: 24 + Max: 38 + Range: 14 + Mean: 30 + Median: 29 + Mode: (26, 5) + Variance: 17.5 + Standard Deviation: 4.2 + Frequency Distribution: [(20.0, 26), (16.0, 27), (12.0, 32), (8.0, 37), (8.0, 34), (8.0, 33), (8.0, 31), (8.0, 24), (4.0, 38), (4.0, 29), (4.0, 25)] + ``` 🎉 CONGRATULATIONS ! 🎉 -[<< Day 8](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/08_Day/08_day_objects.md) | [Day 10 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/10_Day/10_day_Set_and_Map.md) +[<< Day 8](../08_Day_Objects/08_day_objects.md) | [Day 10 >>](../10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md) diff --git a/09_Day/09_day_starter/data/countries_data.js b/09_Day_Higher_order_functions/09_day_starter/data/countries_data.js similarity index 100% rename from 09_Day/09_day_starter/data/countries_data.js rename to 09_Day_Higher_order_functions/09_day_starter/data/countries_data.js diff --git a/09_Day/09_day_starter/index.html b/09_Day_Higher_order_functions/09_day_starter/index.html similarity index 100% rename from 09_Day/09_day_starter/index.html rename to 09_Day_Higher_order_functions/09_day_starter/index.html diff --git a/09_Day/09_day_starter/scripts/main.js b/09_Day_Higher_order_functions/09_day_starter/scripts/main.js similarity index 100% rename from 09_Day/09_day_starter/scripts/main.js rename to 09_Day_Higher_order_functions/09_day_starter/scripts/main.js diff --git a/10_Day/10_day_Set_and_Map.md b/10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md similarity index 86% rename from 10_Day/10_day_Set_and_Map.md rename to 10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md index f5dddf0..a978a88 100644 --- a/10_Day/10_day_Set_and_Map.md +++ b/10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Sets and Maps

@@ -13,9 +13,9 @@
-[<< Day 9](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/09_Day/09_day_higher_order_functions.md) | [Day 11>>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/11_Day/11_destructuring_and_spreading.md) +[<< Day 9](../09_Day_Higher_order_functions/09_day_higher_order_functions.md) | [Day 11>>](../11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md) -![Day 5](../images/banners/day_1_10.png) +![Day 10](../images/banners/day_1_10.png) - [Day 10](#day-10) - [Set](#set) @@ -35,6 +35,9 @@ - [Getting a value from Map](#getting-a-value-from-map) - [Checking key in Map](#checking-key-in-map) - [Exercises](#exercises) + - [Exercises:Level 1](#exerciseslevel-1) + - [Exercises:Level 2](#exerciseslevel-2) + - [Exercises:Level 3](#exerciseslevel-3) # Day 10 @@ -384,39 +387,61 @@ Norway Oslo ## Exercises +### Exercises:Level 1 + +```js +const a = {4, 5, 8, 9} +const b = {3, 4, 5, 7} +const countries = ['Finland', 'Sweden', 'Norway'] +``` + 1. create an empty set 2. Create a set containing 0 to 10 using loop 3. Remove an element from a set 4. Clear a set 5. Create a set of 5 string elements from array 6. Create a map of countries and number of characters of a country -7. \*\*\* Find the 10 most spoken languages: - ````js +### Exercises:Level 2 + +1. Find a union b +2. Find a intersection b +3. Find a with b + +### Exercises:Level 3 + +1. How many languages are there in the countries object file. + +1. \*\*\* Use the countries data to find the 10 most spoken languages: + + ```js // Your output should look like this console.log(mostSpokenLanguages(countries, 10)) - [(91, 'English'), - (45, 'French'), - (25, 'Arabic'), - (24, 'Spanish'), - (9, 'Russian'), - (9, 'Portuguese'), - (8, 'Dutch'), - (7, 'German'), - (5, 'Chinese'), - (4, 'Swahili'), - (4, 'Serbian')] + [ + {'English':91}, + {'French':45}, + {'Arabic':25}, + {'Spanish':24}, + {'Russian':9}, + {'Portuguese':9}, + {'Dutch':8}, + {'German':7}, + {'Chinese':5}, + {'Swahili':4}, + {'Serbian':4}] // Your output should look like this console.log(mostSpokenLanguages(countries, 3)) - [ - (91, 'English'), - (45, 'French'), - (25, 'Arabic') - ]``` - ```` + [ + {'English':91}, + {'French':45}, + {'Arabic':25} + ] + ``` + 🎉 CONGRATULATIONS ! 🎉 -[<< Day 9](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/09_Day/09_day_higher_order_functions.md) | [Day 11>>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/11_Day/11_destructuring_and_spreading.md) + +[<< Day 9](../09_Day_Higher_order_functions/09_day_higher_order_functions.md) | [Day 11>>](../11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md) diff --git a/10_Day_Sets_and_Maps/10_day_starter/data/countries_data.js b/10_Day_Sets_and_Maps/10_day_starter/data/countries_data.js new file mode 100644 index 0000000..92acddd --- /dev/null +++ b/10_Day_Sets_and_Maps/10_day_starter/data/countries_data.js @@ -0,0 +1,2013 @@ +const countries = [ + { + name: 'Afghanistan', + capital: 'Kabul', + languages: ['Pashto', 'Uzbek', 'Turkmen'], + population: 27657145, + flag: 'https://restcountries.eu/data/afg.svg', + currency: 'Afghan afghani' + }, + { + name: 'Åland Islands', + capital: 'Mariehamn', + languages: ['Swedish'], + population: 28875, + flag: 'https://restcountries.eu/data/ala.svg', + currency: 'Euro' + }, + { + name: 'Albania', + capital: 'Tirana', + languages: ['Albanian'], + population: 2886026, + flag: 'https://restcountries.eu/data/alb.svg', + currency: 'Albanian lek' + }, + { + name: 'Algeria', + capital: 'Algiers', + languages: ['Arabic'], + population: 40400000, + flag: 'https://restcountries.eu/data/dza.svg', + currency: 'Algerian dinar' + }, + { + name: 'American Samoa', + capital: 'Pago Pago', + languages: ['English', 'Samoan'], + population: 57100, + flag: 'https://restcountries.eu/data/asm.svg', + currency: 'United State Dollar' + }, + { + name: 'Andorra', + capital: 'Andorra la Vella', + languages: ['Catalan'], + population: 78014, + flag: 'https://restcountries.eu/data/and.svg', + currency: 'Euro' + }, + { + name: 'Angola', + capital: 'Luanda', + languages: ['Portuguese'], + population: 25868000, + flag: 'https://restcountries.eu/data/ago.svg', + currency: 'Angolan kwanza' + }, + { + name: 'Anguilla', + capital: 'The Valley', + languages: ['English'], + population: 13452, + flag: 'https://restcountries.eu/data/aia.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Antarctica', + capital: '', + languages: ['English', 'Russian'], + population: 1000, + flag: 'https://restcountries.eu/data/ata.svg', + currency: 'Australian dollar' + }, + { + name: 'Antigua and Barbuda', + capital: "Saint John's", + languages: ['English'], + population: 86295, + flag: 'https://restcountries.eu/data/atg.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Argentina', + capital: 'Buenos Aires', + languages: ['Spanish', 'Guaraní'], + population: 43590400, + flag: 'https://restcountries.eu/data/arg.svg', + currency: 'Argentine peso' + }, + { + name: 'Armenia', + capital: 'Yerevan', + languages: ['Armenian', 'Russian'], + population: 2994400, + flag: 'https://restcountries.eu/data/arm.svg', + currency: 'Armenian dram' + }, + { + name: 'Aruba', + capital: 'Oranjestad', + languages: ['Dutch', '(Eastern) Punjabi'], + population: 107394, + flag: 'https://restcountries.eu/data/abw.svg', + currency: 'Aruban florin' + }, + { + name: 'Australia', + capital: 'Canberra', + languages: ['English'], + population: 24117360, + flag: 'https://restcountries.eu/data/aus.svg', + currency: 'Australian dollar' + }, + { + name: 'Austria', + capital: 'Vienna', + languages: ['German'], + population: 8725931, + flag: 'https://restcountries.eu/data/aut.svg', + currency: 'Euro' + }, + { + name: 'Azerbaijan', + capital: 'Baku', + languages: ['Azerbaijani'], + population: 9730500, + flag: 'https://restcountries.eu/data/aze.svg', + currency: 'Azerbaijani manat' + }, + { + name: 'Bahamas', + capital: 'Nassau', + languages: ['English'], + population: 378040, + flag: 'https://restcountries.eu/data/bhs.svg', + currency: 'Bahamian dollar' + }, + { + name: 'Bahrain', + capital: 'Manama', + languages: ['Arabic'], + population: 1404900, + flag: 'https://restcountries.eu/data/bhr.svg', + currency: 'Bahraini dinar' + }, + { + name: 'Bangladesh', + capital: 'Dhaka', + languages: ['Bengali'], + population: 161006790, + flag: 'https://restcountries.eu/data/bgd.svg', + currency: 'Bangladeshi taka' + }, + { + name: 'Barbados', + capital: 'Bridgetown', + languages: ['English'], + population: 285000, + flag: 'https://restcountries.eu/data/brb.svg', + currency: 'Barbadian dollar' + }, + { + name: 'Belarus', + capital: 'Minsk', + languages: ['Belarusian', 'Russian'], + population: 9498700, + flag: 'https://restcountries.eu/data/blr.svg', + currency: 'New Belarusian ruble' + }, + { + name: 'Belgium', + capital: 'Brussels', + languages: ['Dutch', 'French', 'German'], + population: 11319511, + flag: 'https://restcountries.eu/data/bel.svg', + currency: 'Euro' + }, + { + name: 'Belize', + capital: 'Belmopan', + languages: ['English', 'Spanish'], + population: 370300, + flag: 'https://restcountries.eu/data/blz.svg', + currency: 'Belize dollar' + }, + { + name: 'Benin', + capital: 'Porto-Novo', + languages: ['French'], + population: 10653654, + flag: 'https://restcountries.eu/data/ben.svg', + currency: 'West African CFA franc' + }, + { + name: 'Bermuda', + capital: 'Hamilton', + languages: ['English'], + population: 61954, + flag: 'https://restcountries.eu/data/bmu.svg', + currency: 'Bermudian dollar' + }, + { + name: 'Bhutan', + capital: 'Thimphu', + languages: ['Dzongkha'], + population: 775620, + flag: 'https://restcountries.eu/data/btn.svg', + currency: 'Bhutanese ngultrum' + }, + { + name: 'Bolivia (Plurinational State of)', + capital: 'Sucre', + languages: ['Spanish', 'Aymara', 'Quechua'], + population: 10985059, + flag: 'https://restcountries.eu/data/bol.svg', + currency: 'Bolivian boliviano' + }, + { + name: 'Bonaire, Sint Eustatius and Saba', + capital: 'Kralendijk', + languages: ['Dutch'], + population: 17408, + flag: 'https://restcountries.eu/data/bes.svg', + currency: 'United States dollar' + }, + { + name: 'Bosnia and Herzegovina', + capital: 'Sarajevo', + languages: ['Bosnian', 'Croatian', 'Serbian'], + population: 3531159, + flag: 'https://restcountries.eu/data/bih.svg', + currency: 'Bosnia and Herzegovina convertible mark' + }, + { + name: 'Botswana', + capital: 'Gaborone', + languages: ['English', 'Tswana'], + population: 2141206, + flag: 'https://restcountries.eu/data/bwa.svg', + currency: 'Botswana pula' + }, + { + name: 'Bouvet Island', + capital: '', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 0, + flag: 'https://restcountries.eu/data/bvt.svg', + currency: 'Norwegian krone' + }, + { + name: 'Brazil', + capital: 'Brasília', + languages: ['Portuguese'], + population: 206135893, + flag: 'https://restcountries.eu/data/bra.svg', + currency: 'Brazilian real' + }, + { + name: 'British Indian Ocean Territory', + capital: 'Diego Garcia', + languages: ['English'], + population: 3000, + flag: 'https://restcountries.eu/data/iot.svg', + currency: 'United States dollar' + }, + { + name: 'United States Minor Outlying Islands', + capital: '', + languages: ['English'], + population: 300, + flag: 'https://restcountries.eu/data/umi.svg', + currency: 'United States Dollar' + }, + { + name: 'Virgin Islands (British)', + capital: 'Road Town', + languages: ['English'], + population: 28514, + flag: 'https://restcountries.eu/data/vgb.svg', + currency: '[D]' + }, + { + name: 'Virgin Islands (U.S.)', + capital: 'Charlotte Amalie', + languages: ['English'], + population: 114743, + flag: 'https://restcountries.eu/data/vir.svg', + currency: 'United States dollar' + }, + { + name: 'Brunei Darussalam', + capital: 'Bandar Seri Begawan', + languages: ['Malay'], + population: 411900, + flag: 'https://restcountries.eu/data/brn.svg', + currency: 'Brunei dollar' + }, + { + name: 'Bulgaria', + capital: 'Sofia', + languages: ['Bulgarian'], + population: 7153784, + flag: 'https://restcountries.eu/data/bgr.svg', + currency: 'Bulgarian lev' + }, + { + name: 'Burkina Faso', + capital: 'Ouagadougou', + languages: ['French', 'Fula'], + population: 19034397, + flag: 'https://restcountries.eu/data/bfa.svg', + currency: 'West African CFA franc' + }, + { + name: 'Burundi', + capital: 'Bujumbura', + languages: ['French', 'Kirundi'], + population: 10114505, + flag: 'https://restcountries.eu/data/bdi.svg', + currency: 'Burundian franc' + }, + { + name: 'Cambodia', + capital: 'Phnom Penh', + languages: ['Khmer'], + population: 15626444, + flag: 'https://restcountries.eu/data/khm.svg', + currency: 'Cambodian riel' + }, + { + name: 'Cameroon', + capital: 'Yaoundé', + languages: ['English', 'French'], + population: 22709892, + flag: 'https://restcountries.eu/data/cmr.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Canada', + capital: 'Ottawa', + languages: ['English', 'French'], + population: 36155487, + flag: 'https://restcountries.eu/data/can.svg', + currency: 'Canadian dollar' + }, + { + name: 'Cabo Verde', + capital: 'Praia', + languages: ['Portuguese'], + population: 531239, + flag: 'https://restcountries.eu/data/cpv.svg', + currency: 'Cape Verdean escudo' + }, + { + name: 'Cayman Islands', + capital: 'George Town', + languages: ['English'], + population: 58238, + flag: 'https://restcountries.eu/data/cym.svg', + currency: 'Cayman Islands dollar' + }, + { + name: 'Central African Republic', + capital: 'Bangui', + languages: ['French', 'Sango'], + population: 4998000, + flag: 'https://restcountries.eu/data/caf.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chad', + capital: "N'Djamena", + languages: ['French', 'Arabic'], + population: 14497000, + flag: 'https://restcountries.eu/data/tcd.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chile', + capital: 'Santiago', + languages: ['Spanish'], + population: 18191900, + flag: 'https://restcountries.eu/data/chl.svg', + currency: 'Chilean peso' + }, + { + name: 'China', + capital: 'Beijing', + languages: ['Chinese'], + population: 1377422166, + flag: 'https://restcountries.eu/data/chn.svg', + currency: 'Chinese yuan' + }, + { + name: 'Christmas Island', + capital: 'Flying Fish Cove', + languages: ['English'], + population: 2072, + flag: 'https://restcountries.eu/data/cxr.svg', + currency: 'Australian dollar' + }, + { + name: 'Cocos (Keeling) Islands', + capital: 'West Island', + languages: ['English'], + population: 550, + flag: 'https://restcountries.eu/data/cck.svg', + currency: 'Australian dollar' + }, + { + name: 'Colombia', + capital: 'Bogotá', + languages: ['Spanish'], + population: 48759958, + flag: 'https://restcountries.eu/data/col.svg', + currency: 'Colombian peso' + }, + { + name: 'Comoros', + capital: 'Moroni', + languages: ['Arabic', 'French'], + population: 806153, + flag: 'https://restcountries.eu/data/com.svg', + currency: 'Comorian franc' + }, + { + name: 'Congo', + capital: 'Brazzaville', + languages: ['French', 'Lingala'], + population: 4741000, + flag: 'https://restcountries.eu/data/cog.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Congo (Democratic Republic of the)', + capital: 'Kinshasa', + languages: ['French', 'Lingala', 'Kongo', 'Swahili', 'Luba-Katanga'], + population: 85026000, + flag: 'https://restcountries.eu/data/cod.svg', + currency: 'Congolese franc' + }, + { + name: 'Cook Islands', + capital: 'Avarua', + languages: ['English'], + population: 18100, + flag: 'https://restcountries.eu/data/cok.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Costa Rica', + capital: 'San José', + languages: ['Spanish'], + population: 4890379, + flag: 'https://restcountries.eu/data/cri.svg', + currency: 'Costa Rican colón' + }, + { + name: 'Croatia', + capital: 'Zagreb', + languages: ['Croatian'], + population: 4190669, + flag: 'https://restcountries.eu/data/hrv.svg', + currency: 'Croatian kuna' + }, + { + name: 'Cuba', + capital: 'Havana', + languages: ['Spanish'], + population: 11239004, + flag: 'https://restcountries.eu/data/cub.svg', + currency: 'Cuban convertible peso' + }, + { + name: 'Curaçao', + capital: 'Willemstad', + languages: ['Dutch', '(Eastern) Punjabi', 'English'], + population: 154843, + flag: 'https://restcountries.eu/data/cuw.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Cyprus', + capital: 'Nicosia', + languages: ['Greek (modern)', 'Turkish', 'Armenian'], + population: 847000, + flag: 'https://restcountries.eu/data/cyp.svg', + currency: 'Euro' + }, + { + name: 'Czech Republic', + capital: 'Prague', + languages: ['Czech', 'Slovak'], + population: 10558524, + flag: 'https://restcountries.eu/data/cze.svg', + currency: 'Czech koruna' + }, + { + name: 'Denmark', + capital: 'Copenhagen', + languages: ['Danish'], + population: 5717014, + flag: 'https://restcountries.eu/data/dnk.svg', + currency: 'Danish krone' + }, + { + name: 'Djibouti', + capital: 'Djibouti', + languages: ['French', 'Arabic'], + population: 900000, + flag: 'https://restcountries.eu/data/dji.svg', + currency: 'Djiboutian franc' + }, + { + name: 'Dominica', + capital: 'Roseau', + languages: ['English'], + population: 71293, + flag: 'https://restcountries.eu/data/dma.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Dominican Republic', + capital: 'Santo Domingo', + languages: ['Spanish'], + population: 10075045, + flag: 'https://restcountries.eu/data/dom.svg', + currency: 'Dominican peso' + }, + { + name: 'Ecuador', + capital: 'Quito', + languages: ['Spanish'], + population: 16545799, + flag: 'https://restcountries.eu/data/ecu.svg', + currency: 'United States dollar' + }, + { + name: 'Egypt', + capital: 'Cairo', + languages: ['Arabic'], + population: 91290000, + flag: 'https://restcountries.eu/data/egy.svg', + currency: 'Egyptian pound' + }, + { + name: 'El Salvador', + capital: 'San Salvador', + languages: ['Spanish'], + population: 6520675, + flag: 'https://restcountries.eu/data/slv.svg', + currency: 'United States dollar' + }, + { + name: 'Equatorial Guinea', + capital: 'Malabo', + languages: ['Spanish', 'French'], + population: 1222442, + flag: 'https://restcountries.eu/data/gnq.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Eritrea', + capital: 'Asmara', + languages: ['Tigrinya', 'Arabic', 'English'], + population: 5352000, + flag: 'https://restcountries.eu/data/eri.svg', + currency: 'Eritrean nakfa' + }, + { + name: 'Estonia', + capital: 'Tallinn', + languages: ['Estonian'], + population: 1315944, + flag: 'https://restcountries.eu/data/est.svg', + currency: 'Euro' + }, + { + name: 'Ethiopia', + capital: 'Addis Ababa', + languages: ['Amharic'], + population: 92206005, + flag: 'https://restcountries.eu/data/eth.svg', + currency: 'Ethiopian birr' + }, + { + name: 'Falkland Islands (Malvinas)', + capital: 'Stanley', + languages: ['English'], + population: 2563, + flag: 'https://restcountries.eu/data/flk.svg', + currency: 'Falkland Islands pound' + }, + { + name: 'Faroe Islands', + capital: 'Tórshavn', + languages: ['Faroese'], + population: 49376, + flag: 'https://restcountries.eu/data/fro.svg', + currency: 'Danish krone' + }, + { + name: 'Fiji', + capital: 'Suva', + languages: ['English', 'Fijian', 'Hindi', 'Urdu'], + population: 867000, + flag: 'https://restcountries.eu/data/fji.svg', + currency: 'Fijian dollar' + }, + { + name: 'Finland', + capital: 'Helsinki', + languages: ['Finnish', 'Swedish'], + population: 5491817, + flag: 'https://restcountries.eu/data/fin.svg', + currency: 'Euro' + }, + { + name: 'France', + capital: 'Paris', + languages: ['French'], + population: 66710000, + flag: 'https://restcountries.eu/data/fra.svg', + currency: 'Euro' + }, + { + name: 'French Guiana', + capital: 'Cayenne', + languages: ['French'], + population: 254541, + flag: 'https://restcountries.eu/data/guf.svg', + currency: 'Euro' + }, + { + name: 'French Polynesia', + capital: 'Papeetē', + languages: ['French'], + population: 271800, + flag: 'https://restcountries.eu/data/pyf.svg', + currency: 'CFP franc' + }, + { + name: 'French Southern Territories', + capital: 'Port-aux-Français', + languages: ['French'], + population: 140, + flag: 'https://restcountries.eu/data/atf.svg', + currency: 'Euro' + }, + { + name: 'Gabon', + capital: 'Libreville', + languages: ['French'], + population: 1802278, + flag: 'https://restcountries.eu/data/gab.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Gambia', + capital: 'Banjul', + languages: ['English'], + population: 1882450, + flag: 'https://restcountries.eu/data/gmb.svg', + currency: 'Gambian dalasi' + }, + { + name: 'Georgia', + capital: 'Tbilisi', + languages: ['Georgian'], + population: 3720400, + flag: 'https://restcountries.eu/data/geo.svg', + currency: 'Georgian Lari' + }, + { + name: 'Germany', + capital: 'Berlin', + languages: ['German'], + population: 81770900, + flag: 'https://restcountries.eu/data/deu.svg', + currency: 'Euro' + }, + { + name: 'Ghana', + capital: 'Accra', + languages: ['English'], + population: 27670174, + flag: 'https://restcountries.eu/data/gha.svg', + currency: 'Ghanaian cedi' + }, + { + name: 'Gibraltar', + capital: 'Gibraltar', + languages: ['English'], + population: 33140, + flag: 'https://restcountries.eu/data/gib.svg', + currency: 'Gibraltar pound' + }, + { + name: 'Greece', + capital: 'Athens', + languages: ['Greek (modern)'], + population: 10858018, + flag: 'https://restcountries.eu/data/grc.svg', + currency: 'Euro' + }, + { + name: 'Greenland', + capital: 'Nuuk', + languages: ['Kalaallisut'], + population: 55847, + flag: 'https://restcountries.eu/data/grl.svg', + currency: 'Danish krone' + }, + { + name: 'Grenada', + capital: "St. George's", + languages: ['English'], + population: 103328, + flag: 'https://restcountries.eu/data/grd.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Guadeloupe', + capital: 'Basse-Terre', + languages: ['French'], + population: 400132, + flag: 'https://restcountries.eu/data/glp.svg', + currency: 'Euro' + }, + { + name: 'Guam', + capital: 'Hagåtña', + languages: ['English', 'Chamorro', 'Spanish'], + population: 184200, + flag: 'https://restcountries.eu/data/gum.svg', + currency: 'United States dollar' + }, + { + name: 'Guatemala', + capital: 'Guatemala City', + languages: ['Spanish'], + population: 16176133, + flag: 'https://restcountries.eu/data/gtm.svg', + currency: 'Guatemalan quetzal' + }, + { + name: 'Guernsey', + capital: 'St. Peter Port', + languages: ['English', 'French'], + population: 62999, + flag: 'https://restcountries.eu/data/ggy.svg', + currency: 'British pound' + }, + { + name: 'Guinea', + capital: 'Conakry', + languages: ['French', 'Fula'], + population: 12947000, + flag: 'https://restcountries.eu/data/gin.svg', + currency: 'Guinean franc' + }, + { + name: 'Guinea-Bissau', + capital: 'Bissau', + languages: ['Portuguese'], + population: 1547777, + flag: 'https://restcountries.eu/data/gnb.svg', + currency: 'West African CFA franc' + }, + { + name: 'Guyana', + capital: 'Georgetown', + languages: ['English'], + population: 746900, + flag: 'https://restcountries.eu/data/guy.svg', + currency: 'Guyanese dollar' + }, + { + name: 'Haiti', + capital: 'Port-au-Prince', + languages: ['French', 'Haitian'], + population: 11078033, + flag: 'https://restcountries.eu/data/hti.svg', + currency: 'Haitian gourde' + }, + { + name: 'Heard Island and McDonald Islands', + capital: '', + languages: ['English'], + population: 0, + flag: 'https://restcountries.eu/data/hmd.svg', + currency: 'Australian dollar' + }, + { + name: 'Holy See', + capital: 'Rome', + languages: ['Latin', 'Italian', 'French', 'German'], + population: 451, + flag: 'https://restcountries.eu/data/vat.svg', + currency: 'Euro' + }, + { + name: 'Honduras', + capital: 'Tegucigalpa', + languages: ['Spanish'], + population: 8576532, + flag: 'https://restcountries.eu/data/hnd.svg', + currency: 'Honduran lempira' + }, + { + name: 'Hong Kong', + capital: 'City of Victoria', + languages: ['English', 'Chinese'], + population: 7324300, + flag: 'https://restcountries.eu/data/hkg.svg', + currency: 'Hong Kong dollar' + }, + { + name: 'Hungary', + capital: 'Budapest', + languages: ['Hungarian'], + population: 9823000, + flag: 'https://restcountries.eu/data/hun.svg', + currency: 'Hungarian forint' + }, + { + name: 'Iceland', + capital: 'Reykjavík', + languages: ['Icelandic'], + population: 334300, + flag: 'https://restcountries.eu/data/isl.svg', + currency: 'Icelandic króna' + }, + { + name: 'India', + capital: 'New Delhi', + languages: ['Hindi', 'English'], + population: 1295210000, + flag: 'https://restcountries.eu/data/ind.svg', + currency: 'Indian rupee' + }, + { + name: 'Indonesia', + capital: 'Jakarta', + languages: ['Indonesian'], + population: 258705000, + flag: 'https://restcountries.eu/data/idn.svg', + currency: 'Indonesian rupiah' + }, + { + name: "Côte d'Ivoire", + capital: 'Yamoussoukro', + languages: ['French'], + population: 22671331, + flag: 'https://restcountries.eu/data/civ.svg', + currency: 'West African CFA franc' + }, + { + name: 'Iran (Islamic Republic of)', + capital: 'Tehran', + languages: ['Persian (Farsi)'], + population: 79369900, + flag: 'https://restcountries.eu/data/irn.svg', + currency: 'Iranian rial' + }, + { + name: 'Iraq', + capital: 'Baghdad', + languages: ['Arabic', 'Kurdish'], + population: 37883543, + flag: 'https://restcountries.eu/data/irq.svg', + currency: 'Iraqi dinar' + }, + { + name: 'Ireland', + capital: 'Dublin', + languages: ['Irish', 'English'], + population: 6378000, + flag: 'https://restcountries.eu/data/irl.svg', + currency: 'Euro' + }, + { + name: 'Isle of Man', + capital: 'Douglas', + languages: ['English', 'Manx'], + population: 84497, + flag: 'https://restcountries.eu/data/imn.svg', + currency: 'British pound' + }, + { + name: 'Israel', + capital: 'Jerusalem', + languages: ['Hebrew (modern)', 'Arabic'], + population: 8527400, + flag: 'https://restcountries.eu/data/isr.svg', + currency: 'Israeli new shekel' + }, + { + name: 'Italy', + capital: 'Rome', + languages: ['Italian'], + population: 60665551, + flag: 'https://restcountries.eu/data/ita.svg', + currency: 'Euro' + }, + { + name: 'Jamaica', + capital: 'Kingston', + languages: ['English'], + population: 2723246, + flag: 'https://restcountries.eu/data/jam.svg', + currency: 'Jamaican dollar' + }, + { + name: 'Japan', + capital: 'Tokyo', + languages: ['Japanese'], + population: 126960000, + flag: 'https://restcountries.eu/data/jpn.svg', + currency: 'Japanese yen' + }, + { + name: 'Jersey', + capital: 'Saint Helier', + languages: ['English', 'French'], + population: 100800, + flag: 'https://restcountries.eu/data/jey.svg', + currency: 'British pound' + }, + { + name: 'Jordan', + capital: 'Amman', + languages: ['Arabic'], + population: 9531712, + flag: 'https://restcountries.eu/data/jor.svg', + currency: 'Jordanian dinar' + }, + { + name: 'Kazakhstan', + capital: 'Astana', + languages: ['Kazakh', 'Russian'], + population: 17753200, + flag: 'https://restcountries.eu/data/kaz.svg', + currency: 'Kazakhstani tenge' + }, + { + name: 'Kenya', + capital: 'Nairobi', + languages: ['English', 'Swahili'], + population: 47251000, + flag: 'https://restcountries.eu/data/ken.svg', + currency: 'Kenyan shilling' + }, + { + name: 'Kiribati', + capital: 'South Tarawa', + languages: ['English'], + population: 113400, + flag: 'https://restcountries.eu/data/kir.svg', + currency: 'Australian dollar' + }, + { + name: 'Kuwait', + capital: 'Kuwait City', + languages: ['Arabic'], + population: 4183658, + flag: 'https://restcountries.eu/data/kwt.svg', + currency: 'Kuwaiti dinar' + }, + { + name: 'Kyrgyzstan', + capital: 'Bishkek', + languages: ['Kyrgyz', 'Russian'], + population: 6047800, + flag: 'https://restcountries.eu/data/kgz.svg', + currency: 'Kyrgyzstani som' + }, + { + name: "Lao People's Democratic Republic", + capital: 'Vientiane', + languages: ['Lao'], + population: 6492400, + flag: 'https://restcountries.eu/data/lao.svg', + currency: 'Lao kip' + }, + { + name: 'Latvia', + capital: 'Riga', + languages: ['Latvian'], + population: 1961600, + flag: 'https://restcountries.eu/data/lva.svg', + currency: 'Euro' + }, + { + name: 'Lebanon', + capital: 'Beirut', + languages: ['Arabic', 'French'], + population: 5988000, + flag: 'https://restcountries.eu/data/lbn.svg', + currency: 'Lebanese pound' + }, + { + name: 'Lesotho', + capital: 'Maseru', + languages: ['English', 'Southern Sotho'], + population: 1894194, + flag: 'https://restcountries.eu/data/lso.svg', + currency: 'Lesotho loti' + }, + { + name: 'Liberia', + capital: 'Monrovia', + languages: ['English'], + population: 4615000, + flag: 'https://restcountries.eu/data/lbr.svg', + currency: 'Liberian dollar' + }, + { + name: 'Libya', + capital: 'Tripoli', + languages: ['Arabic'], + population: 6385000, + flag: 'https://restcountries.eu/data/lby.svg', + currency: 'Libyan dinar' + }, + { + name: 'Liechtenstein', + capital: 'Vaduz', + languages: ['German'], + population: 37623, + flag: 'https://restcountries.eu/data/lie.svg', + currency: 'Swiss franc' + }, + { + name: 'Lithuania', + capital: 'Vilnius', + languages: ['Lithuanian'], + population: 2872294, + flag: 'https://restcountries.eu/data/ltu.svg', + currency: 'Euro' + }, + { + name: 'Luxembourg', + capital: 'Luxembourg', + languages: ['French', 'German', 'Luxembourgish'], + population: 576200, + flag: 'https://restcountries.eu/data/lux.svg', + currency: 'Euro' + }, + { + name: 'Macao', + capital: '', + languages: ['Chinese', 'Portuguese'], + population: 649100, + flag: 'https://restcountries.eu/data/mac.svg', + currency: 'Macanese pataca' + }, + { + name: 'Macedonia (the former Yugoslav Republic of)', + capital: 'Skopje', + languages: ['Macedonian'], + population: 2058539, + flag: 'https://restcountries.eu/data/mkd.svg', + currency: 'Macedonian denar' + }, + { + name: 'Madagascar', + capital: 'Antananarivo', + languages: ['French', 'Malagasy'], + population: 22434363, + flag: 'https://restcountries.eu/data/mdg.svg', + currency: 'Malagasy ariary' + }, + { + name: 'Malawi', + capital: 'Lilongwe', + languages: ['English', 'Chichewa'], + population: 16832910, + flag: 'https://restcountries.eu/data/mwi.svg', + currency: 'Malawian kwacha' + }, + { + name: 'Malaysia', + capital: 'Kuala Lumpur', + languages: ['Malaysian'], + population: 31405416, + flag: 'https://restcountries.eu/data/mys.svg', + currency: 'Malaysian ringgit' + }, + { + name: 'Maldives', + capital: 'Malé', + languages: ['Divehi'], + population: 344023, + flag: 'https://restcountries.eu/data/mdv.svg', + currency: 'Maldivian rufiyaa' + }, + { + name: 'Mali', + capital: 'Bamako', + languages: ['French'], + population: 18135000, + flag: 'https://restcountries.eu/data/mli.svg', + currency: 'West African CFA franc' + }, + { + name: 'Malta', + capital: 'Valletta', + languages: ['Maltese', 'English'], + population: 425384, + flag: 'https://restcountries.eu/data/mlt.svg', + currency: 'Euro' + }, + { + name: 'Marshall Islands', + capital: 'Majuro', + languages: ['English', 'Marshallese'], + population: 54880, + flag: 'https://restcountries.eu/data/mhl.svg', + currency: 'United States dollar' + }, + { + name: 'Martinique', + capital: 'Fort-de-France', + languages: ['French'], + population: 378243, + flag: 'https://restcountries.eu/data/mtq.svg', + currency: 'Euro' + }, + { + name: 'Mauritania', + capital: 'Nouakchott', + languages: ['Arabic'], + population: 3718678, + flag: 'https://restcountries.eu/data/mrt.svg', + currency: 'Mauritanian ouguiya' + }, + { + name: 'Mauritius', + capital: 'Port Louis', + languages: ['English'], + population: 1262879, + flag: 'https://restcountries.eu/data/mus.svg', + currency: 'Mauritian rupee' + }, + { + name: 'Mayotte', + capital: 'Mamoudzou', + languages: ['French'], + population: 226915, + flag: 'https://restcountries.eu/data/myt.svg', + currency: 'Euro' + }, + { + name: 'Mexico', + capital: 'Mexico City', + languages: ['Spanish'], + population: 122273473, + flag: 'https://restcountries.eu/data/mex.svg', + currency: 'Mexican peso' + }, + { + name: 'Micronesia (Federated States of)', + capital: 'Palikir', + languages: ['English'], + population: 102800, + flag: 'https://restcountries.eu/data/fsm.svg', + currency: '[D]' + }, + { + name: 'Moldova (Republic of)', + capital: 'Chișinău', + languages: ['Romanian'], + population: 3553100, + flag: 'https://restcountries.eu/data/mda.svg', + currency: 'Moldovan leu' + }, + { + name: 'Monaco', + capital: 'Monaco', + languages: ['French'], + population: 38400, + flag: 'https://restcountries.eu/data/mco.svg', + currency: 'Euro' + }, + { + name: 'Mongolia', + capital: 'Ulan Bator', + languages: ['Mongolian'], + population: 3093100, + flag: 'https://restcountries.eu/data/mng.svg', + currency: 'Mongolian tögrög' + }, + { + name: 'Montenegro', + capital: 'Podgorica', + languages: ['Serbian', 'Bosnian', 'Albanian', 'Croatian'], + population: 621810, + flag: 'https://restcountries.eu/data/mne.svg', + currency: 'Euro' + }, + { + name: 'Montserrat', + capital: 'Plymouth', + languages: ['English'], + population: 4922, + flag: 'https://restcountries.eu/data/msr.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Morocco', + capital: 'Rabat', + languages: ['Arabic'], + population: 33337529, + flag: 'https://restcountries.eu/data/mar.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Mozambique', + capital: 'Maputo', + languages: ['Portuguese'], + population: 26423700, + flag: 'https://restcountries.eu/data/moz.svg', + currency: 'Mozambican metical' + }, + { + name: 'Myanmar', + capital: 'Naypyidaw', + languages: ['Burmese'], + population: 51419420, + flag: 'https://restcountries.eu/data/mmr.svg', + currency: 'Burmese kyat' + }, + { + name: 'Namibia', + capital: 'Windhoek', + languages: ['English', 'Afrikaans'], + population: 2324388, + flag: 'https://restcountries.eu/data/nam.svg', + currency: 'Namibian dollar' + }, + { + name: 'Nauru', + capital: 'Yaren', + languages: ['English', 'Nauruan'], + population: 10084, + flag: 'https://restcountries.eu/data/nru.svg', + currency: 'Australian dollar' + }, + { + name: 'Nepal', + capital: 'Kathmandu', + languages: ['Nepali'], + population: 28431500, + flag: 'https://restcountries.eu/data/npl.svg', + currency: 'Nepalese rupee' + }, + { + name: 'Netherlands', + capital: 'Amsterdam', + languages: ['Dutch'], + population: 17019800, + flag: 'https://restcountries.eu/data/nld.svg', + currency: 'Euro' + }, + { + name: 'New Caledonia', + capital: 'Nouméa', + languages: ['French'], + population: 268767, + flag: 'https://restcountries.eu/data/ncl.svg', + currency: 'CFP franc' + }, + { + name: 'New Zealand', + capital: 'Wellington', + languages: ['English', 'Māori'], + population: 4697854, + flag: 'https://restcountries.eu/data/nzl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Nicaragua', + capital: 'Managua', + languages: ['Spanish'], + population: 6262703, + flag: 'https://restcountries.eu/data/nic.svg', + currency: 'Nicaraguan córdoba' + }, + { + name: 'Niger', + capital: 'Niamey', + languages: ['French'], + population: 20715000, + flag: 'https://restcountries.eu/data/ner.svg', + currency: 'West African CFA franc' + }, + { + name: 'Nigeria', + capital: 'Abuja', + languages: ['English'], + population: 186988000, + flag: 'https://restcountries.eu/data/nga.svg', + currency: 'Nigerian naira' + }, + { + name: 'Niue', + capital: 'Alofi', + languages: ['English'], + population: 1470, + flag: 'https://restcountries.eu/data/niu.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Norfolk Island', + capital: 'Kingston', + languages: ['English'], + population: 2302, + flag: 'https://restcountries.eu/data/nfk.svg', + currency: 'Australian dollar' + }, + { + name: "Korea (Democratic People's Republic of)", + capital: 'Pyongyang', + languages: ['Korean'], + population: 25281000, + flag: 'https://restcountries.eu/data/prk.svg', + currency: 'North Korean won' + }, + { + name: 'Northern Mariana Islands', + capital: 'Saipan', + languages: ['English', 'Chamorro'], + population: 56940, + flag: 'https://restcountries.eu/data/mnp.svg', + currency: 'United States dollar' + }, + { + name: 'Norway', + capital: 'Oslo', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 5223256, + flag: 'https://restcountries.eu/data/nor.svg', + currency: 'Norwegian krone' + }, + { + name: 'Oman', + capital: 'Muscat', + languages: ['Arabic'], + population: 4420133, + flag: 'https://restcountries.eu/data/omn.svg', + currency: 'Omani rial' + }, + { + name: 'Pakistan', + capital: 'Islamabad', + languages: ['English', 'Urdu'], + population: 194125062, + flag: 'https://restcountries.eu/data/pak.svg', + currency: 'Pakistani rupee' + }, + { + name: 'Palau', + capital: 'Ngerulmud', + languages: ['English'], + population: 17950, + flag: 'https://restcountries.eu/data/plw.svg', + currency: '[E]' + }, + { + name: 'Palestine, State of', + capital: 'Ramallah', + languages: ['Arabic'], + population: 4682467, + flag: 'https://restcountries.eu/data/pse.svg', + currency: 'Israeli new sheqel' + }, + { + name: 'Panama', + capital: 'Panama City', + languages: ['Spanish'], + population: 3814672, + flag: 'https://restcountries.eu/data/pan.svg', + currency: 'Panamanian balboa' + }, + { + name: 'Papua New Guinea', + capital: 'Port Moresby', + languages: ['English'], + population: 8083700, + flag: 'https://restcountries.eu/data/png.svg', + currency: 'Papua New Guinean kina' + }, + { + name: 'Paraguay', + capital: 'Asunción', + languages: ['Spanish', 'Guaraní'], + population: 6854536, + flag: 'https://restcountries.eu/data/pry.svg', + currency: 'Paraguayan guaraní' + }, + { + name: 'Peru', + capital: 'Lima', + languages: ['Spanish'], + population: 31488700, + flag: 'https://restcountries.eu/data/per.svg', + currency: 'Peruvian sol' + }, + { + name: 'Philippines', + capital: 'Manila', + languages: ['English'], + population: 103279800, + flag: 'https://restcountries.eu/data/phl.svg', + currency: 'Philippine peso' + }, + { + name: 'Pitcairn', + capital: 'Adamstown', + languages: ['English'], + population: 56, + flag: 'https://restcountries.eu/data/pcn.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Poland', + capital: 'Warsaw', + languages: ['Polish'], + population: 38437239, + flag: 'https://restcountries.eu/data/pol.svg', + currency: 'Polish złoty' + }, + { + name: 'Portugal', + capital: 'Lisbon', + languages: ['Portuguese'], + population: 10374822, + flag: 'https://restcountries.eu/data/prt.svg', + currency: 'Euro' + }, + { + name: 'Puerto Rico', + capital: 'San Juan', + languages: ['Spanish', 'English'], + population: 3474182, + flag: 'https://restcountries.eu/data/pri.svg', + currency: 'United States dollar' + }, + { + name: 'Qatar', + capital: 'Doha', + languages: ['Arabic'], + population: 2587564, + flag: 'https://restcountries.eu/data/qat.svg', + currency: 'Qatari riyal' + }, + { + name: 'Republic of Kosovo', + capital: 'Pristina', + languages: ['Albanian', 'Serbian'], + population: 1733842, + flag: 'https://restcountries.eu/data/kos.svg', + currency: 'Euro' + }, + { + name: 'Réunion', + capital: 'Saint-Denis', + languages: ['French'], + population: 840974, + flag: 'https://restcountries.eu/data/reu.svg', + currency: 'Euro' + }, + { + name: 'Romania', + capital: 'Bucharest', + languages: ['Romanian'], + population: 19861408, + flag: 'https://restcountries.eu/data/rou.svg', + currency: 'Romanian leu' + }, + { + name: 'Russian Federation', + capital: 'Moscow', + languages: ['Russian'], + population: 146599183, + flag: 'https://restcountries.eu/data/rus.svg', + currency: 'Russian ruble' + }, + { + name: 'Rwanda', + capital: 'Kigali', + languages: ['Kinyarwanda', 'English', 'French'], + population: 11553188, + flag: 'https://restcountries.eu/data/rwa.svg', + currency: 'Rwandan franc' + }, + { + name: 'Saint Barthélemy', + capital: 'Gustavia', + languages: ['French'], + population: 9417, + flag: 'https://restcountries.eu/data/blm.svg', + currency: 'Euro' + }, + { + name: 'Saint Helena, Ascension and Tristan da Cunha', + capital: 'Jamestown', + languages: ['English'], + population: 4255, + flag: 'https://restcountries.eu/data/shn.svg', + currency: 'Saint Helena pound' + }, + { + name: 'Saint Kitts and Nevis', + capital: 'Basseterre', + languages: ['English'], + population: 46204, + flag: 'https://restcountries.eu/data/kna.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Lucia', + capital: 'Castries', + languages: ['English'], + population: 186000, + flag: 'https://restcountries.eu/data/lca.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Martin (French part)', + capital: 'Marigot', + languages: ['English', 'French', 'Dutch'], + population: 36979, + flag: 'https://restcountries.eu/data/maf.svg', + currency: 'Euro' + }, + { + name: 'Saint Pierre and Miquelon', + capital: 'Saint-Pierre', + languages: ['French'], + population: 6069, + flag: 'https://restcountries.eu/data/spm.svg', + currency: 'Euro' + }, + { + name: 'Saint Vincent and the Grenadines', + capital: 'Kingstown', + languages: ['English'], + population: 109991, + flag: 'https://restcountries.eu/data/vct.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Samoa', + capital: 'Apia', + languages: ['Samoan', 'English'], + population: 194899, + flag: 'https://restcountries.eu/data/wsm.svg', + currency: 'Samoan tālā' + }, + { + name: 'San Marino', + capital: 'City of San Marino', + languages: ['Italian'], + population: 33005, + flag: 'https://restcountries.eu/data/smr.svg', + currency: 'Euro' + }, + { + name: 'Sao Tome and Principe', + capital: 'São Tomé', + languages: ['Portuguese'], + population: 187356, + flag: 'https://restcountries.eu/data/stp.svg', + currency: 'São Tomé and Príncipe dobra' + }, + { + name: 'Saudi Arabia', + capital: 'Riyadh', + languages: ['Arabic'], + population: 32248200, + flag: 'https://restcountries.eu/data/sau.svg', + currency: 'Saudi riyal' + }, + { + name: 'Senegal', + capital: 'Dakar', + languages: ['French'], + population: 14799859, + flag: 'https://restcountries.eu/data/sen.svg', + currency: 'West African CFA franc' + }, + { + name: 'Serbia', + capital: 'Belgrade', + languages: ['Serbian'], + population: 7076372, + flag: 'https://restcountries.eu/data/srb.svg', + currency: 'Serbian dinar' + }, + { + name: 'Seychelles', + capital: 'Victoria', + languages: ['French', 'English'], + population: 91400, + flag: 'https://restcountries.eu/data/syc.svg', + currency: 'Seychellois rupee' + }, + { + name: 'Sierra Leone', + capital: 'Freetown', + languages: ['English'], + population: 7075641, + flag: 'https://restcountries.eu/data/sle.svg', + currency: 'Sierra Leonean leone' + }, + { + name: 'Singapore', + capital: 'Singapore', + languages: ['English', 'Malay', 'Tamil', 'Chinese'], + population: 5535000, + flag: 'https://restcountries.eu/data/sgp.svg', + currency: 'Brunei dollar' + }, + { + name: 'Sint Maarten (Dutch part)', + capital: 'Philipsburg', + languages: ['Dutch', 'English'], + population: 38247, + flag: 'https://restcountries.eu/data/sxm.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Slovakia', + capital: 'Bratislava', + languages: ['Slovak'], + population: 5426252, + flag: 'https://restcountries.eu/data/svk.svg', + currency: 'Euro' + }, + { + name: 'Slovenia', + capital: 'Ljubljana', + languages: ['Slovene'], + population: 2064188, + flag: 'https://restcountries.eu/data/svn.svg', + currency: 'Euro' + }, + { + name: 'Solomon Islands', + capital: 'Honiara', + languages: ['English'], + population: 642000, + flag: 'https://restcountries.eu/data/slb.svg', + currency: 'Solomon Islands dollar' + }, + { + name: 'Somalia', + capital: 'Mogadishu', + languages: ['Somali', 'Arabic'], + population: 11079000, + flag: 'https://restcountries.eu/data/som.svg', + currency: 'Somali shilling' + }, + { + name: 'South Africa', + capital: 'Pretoria', + languages: [ + 'Afrikaans', + 'English', + 'Southern Ndebele', + 'Southern Sotho', + 'Swati', + 'Tswana', + 'Tsonga', + 'Venda', + 'Xhosa', + 'Zulu' + ], + population: 55653654, + flag: 'https://restcountries.eu/data/zaf.svg', + currency: 'South African rand' + }, + { + name: 'South Georgia and the South Sandwich Islands', + capital: 'King Edward Point', + languages: ['English'], + population: 30, + flag: 'https://restcountries.eu/data/sgs.svg', + currency: 'British pound' + }, + { + name: 'Korea (Republic of)', + capital: 'Seoul', + languages: ['Korean'], + population: 50801405, + flag: 'https://restcountries.eu/data/kor.svg', + currency: 'South Korean won' + }, + { + name: 'South Sudan', + capital: 'Juba', + languages: ['English'], + population: 12131000, + flag: 'https://restcountries.eu/data/ssd.svg', + currency: 'South Sudanese pound' + }, + { + name: 'Spain', + capital: 'Madrid', + languages: ['Spanish'], + population: 46438422, + flag: 'https://restcountries.eu/data/esp.svg', + currency: 'Euro' + }, + { + name: 'Sri Lanka', + capital: 'Colombo', + languages: ['Sinhalese', 'Tamil'], + population: 20966000, + flag: 'https://restcountries.eu/data/lka.svg', + currency: 'Sri Lankan rupee' + }, + { + name: 'Sudan', + capital: 'Khartoum', + languages: ['Arabic', 'English'], + population: 39598700, + flag: 'https://restcountries.eu/data/sdn.svg', + currency: 'Sudanese pound' + }, + { + name: 'Suriname', + capital: 'Paramaribo', + languages: ['Dutch'], + population: 541638, + flag: 'https://restcountries.eu/data/sur.svg', + currency: 'Surinamese dollar' + }, + { + name: 'Svalbard and Jan Mayen', + capital: 'Longyearbyen', + languages: ['Norwegian'], + population: 2562, + flag: 'https://restcountries.eu/data/sjm.svg', + currency: 'Norwegian krone' + }, + { + name: 'Swaziland', + capital: 'Lobamba', + languages: ['English', 'Swati'], + population: 1132657, + flag: 'https://restcountries.eu/data/swz.svg', + currency: 'Swazi lilangeni' + }, + { + name: 'Sweden', + capital: 'Stockholm', + languages: ['Swedish'], + population: 9894888, + flag: 'https://restcountries.eu/data/swe.svg', + currency: 'Swedish krona' + }, + { + name: 'Switzerland', + capital: 'Bern', + languages: ['German', 'French', 'Italian'], + population: 8341600, + flag: 'https://restcountries.eu/data/che.svg', + currency: 'Swiss franc' + }, + { + name: 'Syrian Arab Republic', + capital: 'Damascus', + languages: ['Arabic'], + population: 18564000, + flag: 'https://restcountries.eu/data/syr.svg', + currency: 'Syrian pound' + }, + { + name: 'Taiwan', + capital: 'Taipei', + languages: ['Chinese'], + population: 23503349, + flag: 'https://restcountries.eu/data/twn.svg', + currency: 'New Taiwan dollar' + }, + { + name: 'Tajikistan', + capital: 'Dushanbe', + languages: ['Tajik', 'Russian'], + population: 8593600, + flag: 'https://restcountries.eu/data/tjk.svg', + currency: 'Tajikistani somoni' + }, + { + name: 'Tanzania, United Republic of', + capital: 'Dodoma', + languages: ['Swahili', 'English'], + population: 55155000, + flag: 'https://restcountries.eu/data/tza.svg', + currency: 'Tanzanian shilling' + }, + { + name: 'Thailand', + capital: 'Bangkok', + languages: ['Thai'], + population: 65327652, + flag: 'https://restcountries.eu/data/tha.svg', + currency: 'Thai baht' + }, + { + name: 'Timor-Leste', + capital: 'Dili', + languages: ['Portuguese'], + population: 1167242, + flag: 'https://restcountries.eu/data/tls.svg', + currency: 'United States dollar' + }, + { + name: 'Togo', + capital: 'Lomé', + languages: ['French'], + population: 7143000, + flag: 'https://restcountries.eu/data/tgo.svg', + currency: 'West African CFA franc' + }, + { + name: 'Tokelau', + capital: 'Fakaofo', + languages: ['English'], + population: 1411, + flag: 'https://restcountries.eu/data/tkl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Tonga', + capital: "Nuku'alofa", + languages: ['English', 'Tonga (Tonga Islands)'], + population: 103252, + flag: 'https://restcountries.eu/data/ton.svg', + currency: 'Tongan paʻanga' + }, + { + name: 'Trinidad and Tobago', + capital: 'Port of Spain', + languages: ['English'], + population: 1349667, + flag: 'https://restcountries.eu/data/tto.svg', + currency: 'Trinidad and Tobago dollar' + }, + { + name: 'Tunisia', + capital: 'Tunis', + languages: ['Arabic'], + population: 11154400, + flag: 'https://restcountries.eu/data/tun.svg', + currency: 'Tunisian dinar' + }, + { + name: 'Turkey', + capital: 'Ankara', + languages: ['Turkish'], + population: 78741053, + flag: 'https://restcountries.eu/data/tur.svg', + currency: 'Turkish lira' + }, + { + name: 'Turkmenistan', + capital: 'Ashgabat', + languages: ['Turkmen', 'Russian'], + population: 4751120, + flag: 'https://restcountries.eu/data/tkm.svg', + currency: 'Turkmenistan manat' + }, + { + name: 'Turks and Caicos Islands', + capital: 'Cockburn Town', + languages: ['English'], + population: 31458, + flag: 'https://restcountries.eu/data/tca.svg', + currency: 'United States dollar' + }, + { + name: 'Tuvalu', + capital: 'Funafuti', + languages: ['English'], + population: 10640, + flag: 'https://restcountries.eu/data/tuv.svg', + currency: 'Australian dollar' + }, + { + name: 'Uganda', + capital: 'Kampala', + languages: ['English', 'Swahili'], + population: 33860700, + flag: 'https://restcountries.eu/data/uga.svg', + currency: 'Ugandan shilling' + }, + { + name: 'Ukraine', + capital: 'Kiev', + languages: ['Ukrainian'], + population: 42692393, + flag: 'https://restcountries.eu/data/ukr.svg', + currency: 'Ukrainian hryvnia' + }, + { + name: 'United Arab Emirates', + capital: 'Abu Dhabi', + languages: ['Arabic'], + population: 9856000, + flag: 'https://restcountries.eu/data/are.svg', + currency: 'United Arab Emirates dirham' + }, + { + name: 'United Kingdom of Great Britain and Northern Ireland', + capital: 'London', + languages: ['English'], + population: 65110000, + flag: 'https://restcountries.eu/data/gbr.svg', + currency: 'British pound' + }, + { + name: 'United States of America', + capital: 'Washington, D.C.', + languages: ['English'], + population: 323947000, + flag: 'https://restcountries.eu/data/usa.svg', + currency: 'United States dollar' + }, + { + name: 'Uruguay', + capital: 'Montevideo', + languages: ['Spanish'], + population: 3480222, + flag: 'https://restcountries.eu/data/ury.svg', + currency: 'Uruguayan peso' + }, + { + name: 'Uzbekistan', + capital: 'Tashkent', + languages: ['Uzbek', 'Russian'], + population: 31576400, + flag: 'https://restcountries.eu/data/uzb.svg', + currency: "Uzbekistani so'm" + }, + { + name: 'Vanuatu', + capital: 'Port Vila', + languages: ['Bislama', 'English', 'French'], + population: 277500, + flag: 'https://restcountries.eu/data/vut.svg', + currency: 'Vanuatu vatu' + }, + { + name: 'Venezuela (Bolivarian Republic of)', + capital: 'Caracas', + languages: ['Spanish'], + population: 31028700, + flag: 'https://restcountries.eu/data/ven.svg', + currency: 'Venezuelan bolívar' + }, + { + name: 'Viet Nam', + capital: 'Hanoi', + languages: ['Vietnamese'], + population: 92700000, + flag: 'https://restcountries.eu/data/vnm.svg', + currency: 'Vietnamese đồng' + }, + { + name: 'Wallis and Futuna', + capital: 'Mata-Utu', + languages: ['French'], + population: 11750, + flag: 'https://restcountries.eu/data/wlf.svg', + currency: 'CFP franc' + }, + { + name: 'Western Sahara', + capital: 'El Aaiún', + languages: ['Spanish'], + population: 510713, + flag: 'https://restcountries.eu/data/esh.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Yemen', + capital: "Sana'a", + languages: ['Arabic'], + population: 27478000, + flag: 'https://restcountries.eu/data/yem.svg', + currency: 'Yemeni rial' + }, + { + name: 'Zambia', + capital: 'Lusaka', + languages: ['English'], + population: 15933883, + flag: 'https://restcountries.eu/data/zmb.svg', + currency: 'Zambian kwacha' + }, + { + name: 'Zimbabwe', + capital: 'Harare', + languages: ['English', 'Shona', 'Northern Ndebele'], + population: 14240168, + flag: 'https://restcountries.eu/data/zwe.svg', + currency: 'Botswana pula' + } +] diff --git a/10_Day_Sets_and_Maps/10_day_starter/index.html b/10_Day_Sets_and_Maps/10_day_starter/index.html new file mode 100644 index 0000000..38b79a2 --- /dev/null +++ b/10_Day_Sets_and_Maps/10_day_starter/index.html @@ -0,0 +1,17 @@ + + + + + 30DaysOfJavaScript:10 Day + + + +

30DaysOfJavaScript:10 Day

+

Set and Map

+ + + + + + + \ No newline at end of file diff --git a/10_Day_Sets_and_Maps/10_day_starter/scripts/main.js b/10_Day_Sets_and_Maps/10_day_starter/scripts/main.js new file mode 100644 index 0000000..c6045c8 --- /dev/null +++ b/10_Day_Sets_and_Maps/10_day_starter/scripts/main.js @@ -0,0 +1,2 @@ +console.log(countries) +alert('Open the console and check if the countries has been loaded') \ No newline at end of file diff --git a/11_Day/11_destructuring_and_spread.md b/11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md similarity index 78% rename from 11_Day/11_destructuring_and_spread.md rename to 11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md index 11625af..075e986 100644 --- a/11_Day/11_destructuring_and_spread.md +++ b/11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Destructuring and Spreading

@@ -13,9 +13,9 @@
-[<< Day 10](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/09_Day/09_day_Set_and_Map.md) | [Day 12>>](#) +[<< Day 10](../10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md) | [Day 12>>](../12_Day_Regular_expressions/12_day_regular_expressions.md) -![Day 5](../images/banners/day_1_10.png) +![Day 11](../images/banners/day_1_11.png) - [Day 11](#day-11) - [Destructuring and Spread](#destructuring-and-spread) @@ -31,7 +31,10 @@ - [Spread operator to copy array](#spread-operator-to-copy-array) - [Spread operator to copy object](#spread-operator-to-copy-object) - [Spread operator with arrow function](#spread-operator-with-arrow-function) - - [Exercise](#exercise) + - [Exercises](#exercises) + - [Exercises: Level 1](#exercises-level-1) + - [Exercises: Level 2](#exercises-level-2) + - [Exercises: Level 3](#exercises-level-3) # Day 11 @@ -526,7 +529,9 @@ console.log(sumAllNums(1, 2, 3,4,5)) 🌕 You achieved quite a lot so far. Now, your level of JavaScript is upper intermediate. Keep going! You have just completed day 11 challenges and you are 11 steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle. -## Exercise +## Exercises + +### Exercises: Level 1 ```js const constants = [2.72, 3.14, 9.81, 37, 100] @@ -586,10 +591,108 @@ const users = [ 1. Destructure and assign the elements of constants array to e, pi, gravity, humanBodyTemp, waterBoilingTemp. 2. Destructure and assign the elements of countries array to fin, est, sw, den, nor 3. Destructure the rectangle object by its properties or keys. -4. Iterate through the users array and get all the keys of the object using destructuring -5. Find the persons who have less than two skills -6. Destructure the countries object print name, capital, population of all countries +### Exercises: Level 2 + +1. Iterate through the users array and get all the keys of the object using destructuring +2. Find the persons who have less than two skills + + +### Exercises: Level 3 + +1. Destructure the countries object print name, capital, population and languages of all countries +2. A junior developer structure student name, skills and score in array of arrays which may not easy to read. Destructure the following array name to name, skills array to skills, scores array to scores, JavaScript score to jsScore and React score to reactScore variable in one line. + + ```js + const student = ['David', ['HTM', 'CSS', 'JS', 'React'], [98, 85, 90, 95]] + console.log(name, skills, jsScore, reactScore) + ``` + + ```sh + David (4) ["HTM", "CSS", "JS", "React"] 90 95 + ``` + +3. Write a function called *convertArrayToObject* which can convert the array to a structure object. + + ```js + const students = [ + ['David', ['HTM', 'CSS', 'JS', 'React'], [98, 85, 90, 95]], + ['John', ['HTM', 'CSS', 'JS', 'React'], [85, 80, 85, 80]] + ] + + console.log(convertArrayToObject(students)) + [ + { + name: 'David', + skills: ['HTM','CSS','JS','React'], + scores: [98,85,90,95] + }, + { + name: 'John', + skills: ['HTM','CSS','JS','React'], + scores: [85, 80,85,80] + } + ] + ``` + +4. Copy the student object to newStudent without mutating the original object. In the new object add the following ? + +- Add Bootstrap with level 8 to the front end skill sets +- Add Express with level 9 to the back end skill sets +- Add SQL with level 8 to the data base skill sets +- Add SQL without level to the data science skill sets + +```js + const student = { + name: 'David', + age: 25, + skills: { + frontEnd: [ + { skill: 'HTML', level: 10 }, + { skill: 'CSS', level: 8 }, + { skill: 'JS', level: 8 }, + { skill: 'React', level: 9 } + ], + backEnd: [ + { skill: 'Node',level: 7 }, + { skill: 'GraphQL', level: 8 }, + ], + dataBase:[ + { skill: 'MongoDB', level: 7.5 }, + ], + dataScience:['Python', 'R', 'D3.js'] + } + } + ``` + + The copied object output should look like this: + +```js + { + name: 'David', + age: 25, + skills: { + frontEnd: [ + {skill: 'HTML',level: 10}, + {skill: 'CSS',level: 8}, + {skill: 'JS',level: 8}, + {skill: 'React',level: 9}, + {skill: 'BootStrap',level: 8} + ], + backEnd: [ + {skill: 'Node',level: 7}, + {skill: 'GraphQL',level: 8}, + {skill: 'Express',level: 9} + ], + dataBase: [ + { skill: 'MongoDB',level: 7.5}, + { skill: 'SQL',level: 8} + ], + dataScience: ['Python','R','D3.js','SQL'] + } + } + +``` 🎉 CONGRATULATIONS ! 🎉 -[<< Day 10](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/09_Day/09_day_Set_and_Map.md) | [Day 12>>](#) \ No newline at end of file +[<< Day 10](../10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md) | [Day 12>>](../12_Day_Regular_expressions/12_day_regular_expressions.md) \ No newline at end of file diff --git a/11_Day_Destructuring_and_spreading/11_day_starter/data/countries_data.js b/11_Day_Destructuring_and_spreading/11_day_starter/data/countries_data.js new file mode 100644 index 0000000..92acddd --- /dev/null +++ b/11_Day_Destructuring_and_spreading/11_day_starter/data/countries_data.js @@ -0,0 +1,2013 @@ +const countries = [ + { + name: 'Afghanistan', + capital: 'Kabul', + languages: ['Pashto', 'Uzbek', 'Turkmen'], + population: 27657145, + flag: 'https://restcountries.eu/data/afg.svg', + currency: 'Afghan afghani' + }, + { + name: 'Åland Islands', + capital: 'Mariehamn', + languages: ['Swedish'], + population: 28875, + flag: 'https://restcountries.eu/data/ala.svg', + currency: 'Euro' + }, + { + name: 'Albania', + capital: 'Tirana', + languages: ['Albanian'], + population: 2886026, + flag: 'https://restcountries.eu/data/alb.svg', + currency: 'Albanian lek' + }, + { + name: 'Algeria', + capital: 'Algiers', + languages: ['Arabic'], + population: 40400000, + flag: 'https://restcountries.eu/data/dza.svg', + currency: 'Algerian dinar' + }, + { + name: 'American Samoa', + capital: 'Pago Pago', + languages: ['English', 'Samoan'], + population: 57100, + flag: 'https://restcountries.eu/data/asm.svg', + currency: 'United State Dollar' + }, + { + name: 'Andorra', + capital: 'Andorra la Vella', + languages: ['Catalan'], + population: 78014, + flag: 'https://restcountries.eu/data/and.svg', + currency: 'Euro' + }, + { + name: 'Angola', + capital: 'Luanda', + languages: ['Portuguese'], + population: 25868000, + flag: 'https://restcountries.eu/data/ago.svg', + currency: 'Angolan kwanza' + }, + { + name: 'Anguilla', + capital: 'The Valley', + languages: ['English'], + population: 13452, + flag: 'https://restcountries.eu/data/aia.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Antarctica', + capital: '', + languages: ['English', 'Russian'], + population: 1000, + flag: 'https://restcountries.eu/data/ata.svg', + currency: 'Australian dollar' + }, + { + name: 'Antigua and Barbuda', + capital: "Saint John's", + languages: ['English'], + population: 86295, + flag: 'https://restcountries.eu/data/atg.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Argentina', + capital: 'Buenos Aires', + languages: ['Spanish', 'Guaraní'], + population: 43590400, + flag: 'https://restcountries.eu/data/arg.svg', + currency: 'Argentine peso' + }, + { + name: 'Armenia', + capital: 'Yerevan', + languages: ['Armenian', 'Russian'], + population: 2994400, + flag: 'https://restcountries.eu/data/arm.svg', + currency: 'Armenian dram' + }, + { + name: 'Aruba', + capital: 'Oranjestad', + languages: ['Dutch', '(Eastern) Punjabi'], + population: 107394, + flag: 'https://restcountries.eu/data/abw.svg', + currency: 'Aruban florin' + }, + { + name: 'Australia', + capital: 'Canberra', + languages: ['English'], + population: 24117360, + flag: 'https://restcountries.eu/data/aus.svg', + currency: 'Australian dollar' + }, + { + name: 'Austria', + capital: 'Vienna', + languages: ['German'], + population: 8725931, + flag: 'https://restcountries.eu/data/aut.svg', + currency: 'Euro' + }, + { + name: 'Azerbaijan', + capital: 'Baku', + languages: ['Azerbaijani'], + population: 9730500, + flag: 'https://restcountries.eu/data/aze.svg', + currency: 'Azerbaijani manat' + }, + { + name: 'Bahamas', + capital: 'Nassau', + languages: ['English'], + population: 378040, + flag: 'https://restcountries.eu/data/bhs.svg', + currency: 'Bahamian dollar' + }, + { + name: 'Bahrain', + capital: 'Manama', + languages: ['Arabic'], + population: 1404900, + flag: 'https://restcountries.eu/data/bhr.svg', + currency: 'Bahraini dinar' + }, + { + name: 'Bangladesh', + capital: 'Dhaka', + languages: ['Bengali'], + population: 161006790, + flag: 'https://restcountries.eu/data/bgd.svg', + currency: 'Bangladeshi taka' + }, + { + name: 'Barbados', + capital: 'Bridgetown', + languages: ['English'], + population: 285000, + flag: 'https://restcountries.eu/data/brb.svg', + currency: 'Barbadian dollar' + }, + { + name: 'Belarus', + capital: 'Minsk', + languages: ['Belarusian', 'Russian'], + population: 9498700, + flag: 'https://restcountries.eu/data/blr.svg', + currency: 'New Belarusian ruble' + }, + { + name: 'Belgium', + capital: 'Brussels', + languages: ['Dutch', 'French', 'German'], + population: 11319511, + flag: 'https://restcountries.eu/data/bel.svg', + currency: 'Euro' + }, + { + name: 'Belize', + capital: 'Belmopan', + languages: ['English', 'Spanish'], + population: 370300, + flag: 'https://restcountries.eu/data/blz.svg', + currency: 'Belize dollar' + }, + { + name: 'Benin', + capital: 'Porto-Novo', + languages: ['French'], + population: 10653654, + flag: 'https://restcountries.eu/data/ben.svg', + currency: 'West African CFA franc' + }, + { + name: 'Bermuda', + capital: 'Hamilton', + languages: ['English'], + population: 61954, + flag: 'https://restcountries.eu/data/bmu.svg', + currency: 'Bermudian dollar' + }, + { + name: 'Bhutan', + capital: 'Thimphu', + languages: ['Dzongkha'], + population: 775620, + flag: 'https://restcountries.eu/data/btn.svg', + currency: 'Bhutanese ngultrum' + }, + { + name: 'Bolivia (Plurinational State of)', + capital: 'Sucre', + languages: ['Spanish', 'Aymara', 'Quechua'], + population: 10985059, + flag: 'https://restcountries.eu/data/bol.svg', + currency: 'Bolivian boliviano' + }, + { + name: 'Bonaire, Sint Eustatius and Saba', + capital: 'Kralendijk', + languages: ['Dutch'], + population: 17408, + flag: 'https://restcountries.eu/data/bes.svg', + currency: 'United States dollar' + }, + { + name: 'Bosnia and Herzegovina', + capital: 'Sarajevo', + languages: ['Bosnian', 'Croatian', 'Serbian'], + population: 3531159, + flag: 'https://restcountries.eu/data/bih.svg', + currency: 'Bosnia and Herzegovina convertible mark' + }, + { + name: 'Botswana', + capital: 'Gaborone', + languages: ['English', 'Tswana'], + population: 2141206, + flag: 'https://restcountries.eu/data/bwa.svg', + currency: 'Botswana pula' + }, + { + name: 'Bouvet Island', + capital: '', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 0, + flag: 'https://restcountries.eu/data/bvt.svg', + currency: 'Norwegian krone' + }, + { + name: 'Brazil', + capital: 'Brasília', + languages: ['Portuguese'], + population: 206135893, + flag: 'https://restcountries.eu/data/bra.svg', + currency: 'Brazilian real' + }, + { + name: 'British Indian Ocean Territory', + capital: 'Diego Garcia', + languages: ['English'], + population: 3000, + flag: 'https://restcountries.eu/data/iot.svg', + currency: 'United States dollar' + }, + { + name: 'United States Minor Outlying Islands', + capital: '', + languages: ['English'], + population: 300, + flag: 'https://restcountries.eu/data/umi.svg', + currency: 'United States Dollar' + }, + { + name: 'Virgin Islands (British)', + capital: 'Road Town', + languages: ['English'], + population: 28514, + flag: 'https://restcountries.eu/data/vgb.svg', + currency: '[D]' + }, + { + name: 'Virgin Islands (U.S.)', + capital: 'Charlotte Amalie', + languages: ['English'], + population: 114743, + flag: 'https://restcountries.eu/data/vir.svg', + currency: 'United States dollar' + }, + { + name: 'Brunei Darussalam', + capital: 'Bandar Seri Begawan', + languages: ['Malay'], + population: 411900, + flag: 'https://restcountries.eu/data/brn.svg', + currency: 'Brunei dollar' + }, + { + name: 'Bulgaria', + capital: 'Sofia', + languages: ['Bulgarian'], + population: 7153784, + flag: 'https://restcountries.eu/data/bgr.svg', + currency: 'Bulgarian lev' + }, + { + name: 'Burkina Faso', + capital: 'Ouagadougou', + languages: ['French', 'Fula'], + population: 19034397, + flag: 'https://restcountries.eu/data/bfa.svg', + currency: 'West African CFA franc' + }, + { + name: 'Burundi', + capital: 'Bujumbura', + languages: ['French', 'Kirundi'], + population: 10114505, + flag: 'https://restcountries.eu/data/bdi.svg', + currency: 'Burundian franc' + }, + { + name: 'Cambodia', + capital: 'Phnom Penh', + languages: ['Khmer'], + population: 15626444, + flag: 'https://restcountries.eu/data/khm.svg', + currency: 'Cambodian riel' + }, + { + name: 'Cameroon', + capital: 'Yaoundé', + languages: ['English', 'French'], + population: 22709892, + flag: 'https://restcountries.eu/data/cmr.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Canada', + capital: 'Ottawa', + languages: ['English', 'French'], + population: 36155487, + flag: 'https://restcountries.eu/data/can.svg', + currency: 'Canadian dollar' + }, + { + name: 'Cabo Verde', + capital: 'Praia', + languages: ['Portuguese'], + population: 531239, + flag: 'https://restcountries.eu/data/cpv.svg', + currency: 'Cape Verdean escudo' + }, + { + name: 'Cayman Islands', + capital: 'George Town', + languages: ['English'], + population: 58238, + flag: 'https://restcountries.eu/data/cym.svg', + currency: 'Cayman Islands dollar' + }, + { + name: 'Central African Republic', + capital: 'Bangui', + languages: ['French', 'Sango'], + population: 4998000, + flag: 'https://restcountries.eu/data/caf.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chad', + capital: "N'Djamena", + languages: ['French', 'Arabic'], + population: 14497000, + flag: 'https://restcountries.eu/data/tcd.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chile', + capital: 'Santiago', + languages: ['Spanish'], + population: 18191900, + flag: 'https://restcountries.eu/data/chl.svg', + currency: 'Chilean peso' + }, + { + name: 'China', + capital: 'Beijing', + languages: ['Chinese'], + population: 1377422166, + flag: 'https://restcountries.eu/data/chn.svg', + currency: 'Chinese yuan' + }, + { + name: 'Christmas Island', + capital: 'Flying Fish Cove', + languages: ['English'], + population: 2072, + flag: 'https://restcountries.eu/data/cxr.svg', + currency: 'Australian dollar' + }, + { + name: 'Cocos (Keeling) Islands', + capital: 'West Island', + languages: ['English'], + population: 550, + flag: 'https://restcountries.eu/data/cck.svg', + currency: 'Australian dollar' + }, + { + name: 'Colombia', + capital: 'Bogotá', + languages: ['Spanish'], + population: 48759958, + flag: 'https://restcountries.eu/data/col.svg', + currency: 'Colombian peso' + }, + { + name: 'Comoros', + capital: 'Moroni', + languages: ['Arabic', 'French'], + population: 806153, + flag: 'https://restcountries.eu/data/com.svg', + currency: 'Comorian franc' + }, + { + name: 'Congo', + capital: 'Brazzaville', + languages: ['French', 'Lingala'], + population: 4741000, + flag: 'https://restcountries.eu/data/cog.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Congo (Democratic Republic of the)', + capital: 'Kinshasa', + languages: ['French', 'Lingala', 'Kongo', 'Swahili', 'Luba-Katanga'], + population: 85026000, + flag: 'https://restcountries.eu/data/cod.svg', + currency: 'Congolese franc' + }, + { + name: 'Cook Islands', + capital: 'Avarua', + languages: ['English'], + population: 18100, + flag: 'https://restcountries.eu/data/cok.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Costa Rica', + capital: 'San José', + languages: ['Spanish'], + population: 4890379, + flag: 'https://restcountries.eu/data/cri.svg', + currency: 'Costa Rican colón' + }, + { + name: 'Croatia', + capital: 'Zagreb', + languages: ['Croatian'], + population: 4190669, + flag: 'https://restcountries.eu/data/hrv.svg', + currency: 'Croatian kuna' + }, + { + name: 'Cuba', + capital: 'Havana', + languages: ['Spanish'], + population: 11239004, + flag: 'https://restcountries.eu/data/cub.svg', + currency: 'Cuban convertible peso' + }, + { + name: 'Curaçao', + capital: 'Willemstad', + languages: ['Dutch', '(Eastern) Punjabi', 'English'], + population: 154843, + flag: 'https://restcountries.eu/data/cuw.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Cyprus', + capital: 'Nicosia', + languages: ['Greek (modern)', 'Turkish', 'Armenian'], + population: 847000, + flag: 'https://restcountries.eu/data/cyp.svg', + currency: 'Euro' + }, + { + name: 'Czech Republic', + capital: 'Prague', + languages: ['Czech', 'Slovak'], + population: 10558524, + flag: 'https://restcountries.eu/data/cze.svg', + currency: 'Czech koruna' + }, + { + name: 'Denmark', + capital: 'Copenhagen', + languages: ['Danish'], + population: 5717014, + flag: 'https://restcountries.eu/data/dnk.svg', + currency: 'Danish krone' + }, + { + name: 'Djibouti', + capital: 'Djibouti', + languages: ['French', 'Arabic'], + population: 900000, + flag: 'https://restcountries.eu/data/dji.svg', + currency: 'Djiboutian franc' + }, + { + name: 'Dominica', + capital: 'Roseau', + languages: ['English'], + population: 71293, + flag: 'https://restcountries.eu/data/dma.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Dominican Republic', + capital: 'Santo Domingo', + languages: ['Spanish'], + population: 10075045, + flag: 'https://restcountries.eu/data/dom.svg', + currency: 'Dominican peso' + }, + { + name: 'Ecuador', + capital: 'Quito', + languages: ['Spanish'], + population: 16545799, + flag: 'https://restcountries.eu/data/ecu.svg', + currency: 'United States dollar' + }, + { + name: 'Egypt', + capital: 'Cairo', + languages: ['Arabic'], + population: 91290000, + flag: 'https://restcountries.eu/data/egy.svg', + currency: 'Egyptian pound' + }, + { + name: 'El Salvador', + capital: 'San Salvador', + languages: ['Spanish'], + population: 6520675, + flag: 'https://restcountries.eu/data/slv.svg', + currency: 'United States dollar' + }, + { + name: 'Equatorial Guinea', + capital: 'Malabo', + languages: ['Spanish', 'French'], + population: 1222442, + flag: 'https://restcountries.eu/data/gnq.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Eritrea', + capital: 'Asmara', + languages: ['Tigrinya', 'Arabic', 'English'], + population: 5352000, + flag: 'https://restcountries.eu/data/eri.svg', + currency: 'Eritrean nakfa' + }, + { + name: 'Estonia', + capital: 'Tallinn', + languages: ['Estonian'], + population: 1315944, + flag: 'https://restcountries.eu/data/est.svg', + currency: 'Euro' + }, + { + name: 'Ethiopia', + capital: 'Addis Ababa', + languages: ['Amharic'], + population: 92206005, + flag: 'https://restcountries.eu/data/eth.svg', + currency: 'Ethiopian birr' + }, + { + name: 'Falkland Islands (Malvinas)', + capital: 'Stanley', + languages: ['English'], + population: 2563, + flag: 'https://restcountries.eu/data/flk.svg', + currency: 'Falkland Islands pound' + }, + { + name: 'Faroe Islands', + capital: 'Tórshavn', + languages: ['Faroese'], + population: 49376, + flag: 'https://restcountries.eu/data/fro.svg', + currency: 'Danish krone' + }, + { + name: 'Fiji', + capital: 'Suva', + languages: ['English', 'Fijian', 'Hindi', 'Urdu'], + population: 867000, + flag: 'https://restcountries.eu/data/fji.svg', + currency: 'Fijian dollar' + }, + { + name: 'Finland', + capital: 'Helsinki', + languages: ['Finnish', 'Swedish'], + population: 5491817, + flag: 'https://restcountries.eu/data/fin.svg', + currency: 'Euro' + }, + { + name: 'France', + capital: 'Paris', + languages: ['French'], + population: 66710000, + flag: 'https://restcountries.eu/data/fra.svg', + currency: 'Euro' + }, + { + name: 'French Guiana', + capital: 'Cayenne', + languages: ['French'], + population: 254541, + flag: 'https://restcountries.eu/data/guf.svg', + currency: 'Euro' + }, + { + name: 'French Polynesia', + capital: 'Papeetē', + languages: ['French'], + population: 271800, + flag: 'https://restcountries.eu/data/pyf.svg', + currency: 'CFP franc' + }, + { + name: 'French Southern Territories', + capital: 'Port-aux-Français', + languages: ['French'], + population: 140, + flag: 'https://restcountries.eu/data/atf.svg', + currency: 'Euro' + }, + { + name: 'Gabon', + capital: 'Libreville', + languages: ['French'], + population: 1802278, + flag: 'https://restcountries.eu/data/gab.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Gambia', + capital: 'Banjul', + languages: ['English'], + population: 1882450, + flag: 'https://restcountries.eu/data/gmb.svg', + currency: 'Gambian dalasi' + }, + { + name: 'Georgia', + capital: 'Tbilisi', + languages: ['Georgian'], + population: 3720400, + flag: 'https://restcountries.eu/data/geo.svg', + currency: 'Georgian Lari' + }, + { + name: 'Germany', + capital: 'Berlin', + languages: ['German'], + population: 81770900, + flag: 'https://restcountries.eu/data/deu.svg', + currency: 'Euro' + }, + { + name: 'Ghana', + capital: 'Accra', + languages: ['English'], + population: 27670174, + flag: 'https://restcountries.eu/data/gha.svg', + currency: 'Ghanaian cedi' + }, + { + name: 'Gibraltar', + capital: 'Gibraltar', + languages: ['English'], + population: 33140, + flag: 'https://restcountries.eu/data/gib.svg', + currency: 'Gibraltar pound' + }, + { + name: 'Greece', + capital: 'Athens', + languages: ['Greek (modern)'], + population: 10858018, + flag: 'https://restcountries.eu/data/grc.svg', + currency: 'Euro' + }, + { + name: 'Greenland', + capital: 'Nuuk', + languages: ['Kalaallisut'], + population: 55847, + flag: 'https://restcountries.eu/data/grl.svg', + currency: 'Danish krone' + }, + { + name: 'Grenada', + capital: "St. George's", + languages: ['English'], + population: 103328, + flag: 'https://restcountries.eu/data/grd.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Guadeloupe', + capital: 'Basse-Terre', + languages: ['French'], + population: 400132, + flag: 'https://restcountries.eu/data/glp.svg', + currency: 'Euro' + }, + { + name: 'Guam', + capital: 'Hagåtña', + languages: ['English', 'Chamorro', 'Spanish'], + population: 184200, + flag: 'https://restcountries.eu/data/gum.svg', + currency: 'United States dollar' + }, + { + name: 'Guatemala', + capital: 'Guatemala City', + languages: ['Spanish'], + population: 16176133, + flag: 'https://restcountries.eu/data/gtm.svg', + currency: 'Guatemalan quetzal' + }, + { + name: 'Guernsey', + capital: 'St. Peter Port', + languages: ['English', 'French'], + population: 62999, + flag: 'https://restcountries.eu/data/ggy.svg', + currency: 'British pound' + }, + { + name: 'Guinea', + capital: 'Conakry', + languages: ['French', 'Fula'], + population: 12947000, + flag: 'https://restcountries.eu/data/gin.svg', + currency: 'Guinean franc' + }, + { + name: 'Guinea-Bissau', + capital: 'Bissau', + languages: ['Portuguese'], + population: 1547777, + flag: 'https://restcountries.eu/data/gnb.svg', + currency: 'West African CFA franc' + }, + { + name: 'Guyana', + capital: 'Georgetown', + languages: ['English'], + population: 746900, + flag: 'https://restcountries.eu/data/guy.svg', + currency: 'Guyanese dollar' + }, + { + name: 'Haiti', + capital: 'Port-au-Prince', + languages: ['French', 'Haitian'], + population: 11078033, + flag: 'https://restcountries.eu/data/hti.svg', + currency: 'Haitian gourde' + }, + { + name: 'Heard Island and McDonald Islands', + capital: '', + languages: ['English'], + population: 0, + flag: 'https://restcountries.eu/data/hmd.svg', + currency: 'Australian dollar' + }, + { + name: 'Holy See', + capital: 'Rome', + languages: ['Latin', 'Italian', 'French', 'German'], + population: 451, + flag: 'https://restcountries.eu/data/vat.svg', + currency: 'Euro' + }, + { + name: 'Honduras', + capital: 'Tegucigalpa', + languages: ['Spanish'], + population: 8576532, + flag: 'https://restcountries.eu/data/hnd.svg', + currency: 'Honduran lempira' + }, + { + name: 'Hong Kong', + capital: 'City of Victoria', + languages: ['English', 'Chinese'], + population: 7324300, + flag: 'https://restcountries.eu/data/hkg.svg', + currency: 'Hong Kong dollar' + }, + { + name: 'Hungary', + capital: 'Budapest', + languages: ['Hungarian'], + population: 9823000, + flag: 'https://restcountries.eu/data/hun.svg', + currency: 'Hungarian forint' + }, + { + name: 'Iceland', + capital: 'Reykjavík', + languages: ['Icelandic'], + population: 334300, + flag: 'https://restcountries.eu/data/isl.svg', + currency: 'Icelandic króna' + }, + { + name: 'India', + capital: 'New Delhi', + languages: ['Hindi', 'English'], + population: 1295210000, + flag: 'https://restcountries.eu/data/ind.svg', + currency: 'Indian rupee' + }, + { + name: 'Indonesia', + capital: 'Jakarta', + languages: ['Indonesian'], + population: 258705000, + flag: 'https://restcountries.eu/data/idn.svg', + currency: 'Indonesian rupiah' + }, + { + name: "Côte d'Ivoire", + capital: 'Yamoussoukro', + languages: ['French'], + population: 22671331, + flag: 'https://restcountries.eu/data/civ.svg', + currency: 'West African CFA franc' + }, + { + name: 'Iran (Islamic Republic of)', + capital: 'Tehran', + languages: ['Persian (Farsi)'], + population: 79369900, + flag: 'https://restcountries.eu/data/irn.svg', + currency: 'Iranian rial' + }, + { + name: 'Iraq', + capital: 'Baghdad', + languages: ['Arabic', 'Kurdish'], + population: 37883543, + flag: 'https://restcountries.eu/data/irq.svg', + currency: 'Iraqi dinar' + }, + { + name: 'Ireland', + capital: 'Dublin', + languages: ['Irish', 'English'], + population: 6378000, + flag: 'https://restcountries.eu/data/irl.svg', + currency: 'Euro' + }, + { + name: 'Isle of Man', + capital: 'Douglas', + languages: ['English', 'Manx'], + population: 84497, + flag: 'https://restcountries.eu/data/imn.svg', + currency: 'British pound' + }, + { + name: 'Israel', + capital: 'Jerusalem', + languages: ['Hebrew (modern)', 'Arabic'], + population: 8527400, + flag: 'https://restcountries.eu/data/isr.svg', + currency: 'Israeli new shekel' + }, + { + name: 'Italy', + capital: 'Rome', + languages: ['Italian'], + population: 60665551, + flag: 'https://restcountries.eu/data/ita.svg', + currency: 'Euro' + }, + { + name: 'Jamaica', + capital: 'Kingston', + languages: ['English'], + population: 2723246, + flag: 'https://restcountries.eu/data/jam.svg', + currency: 'Jamaican dollar' + }, + { + name: 'Japan', + capital: 'Tokyo', + languages: ['Japanese'], + population: 126960000, + flag: 'https://restcountries.eu/data/jpn.svg', + currency: 'Japanese yen' + }, + { + name: 'Jersey', + capital: 'Saint Helier', + languages: ['English', 'French'], + population: 100800, + flag: 'https://restcountries.eu/data/jey.svg', + currency: 'British pound' + }, + { + name: 'Jordan', + capital: 'Amman', + languages: ['Arabic'], + population: 9531712, + flag: 'https://restcountries.eu/data/jor.svg', + currency: 'Jordanian dinar' + }, + { + name: 'Kazakhstan', + capital: 'Astana', + languages: ['Kazakh', 'Russian'], + population: 17753200, + flag: 'https://restcountries.eu/data/kaz.svg', + currency: 'Kazakhstani tenge' + }, + { + name: 'Kenya', + capital: 'Nairobi', + languages: ['English', 'Swahili'], + population: 47251000, + flag: 'https://restcountries.eu/data/ken.svg', + currency: 'Kenyan shilling' + }, + { + name: 'Kiribati', + capital: 'South Tarawa', + languages: ['English'], + population: 113400, + flag: 'https://restcountries.eu/data/kir.svg', + currency: 'Australian dollar' + }, + { + name: 'Kuwait', + capital: 'Kuwait City', + languages: ['Arabic'], + population: 4183658, + flag: 'https://restcountries.eu/data/kwt.svg', + currency: 'Kuwaiti dinar' + }, + { + name: 'Kyrgyzstan', + capital: 'Bishkek', + languages: ['Kyrgyz', 'Russian'], + population: 6047800, + flag: 'https://restcountries.eu/data/kgz.svg', + currency: 'Kyrgyzstani som' + }, + { + name: "Lao People's Democratic Republic", + capital: 'Vientiane', + languages: ['Lao'], + population: 6492400, + flag: 'https://restcountries.eu/data/lao.svg', + currency: 'Lao kip' + }, + { + name: 'Latvia', + capital: 'Riga', + languages: ['Latvian'], + population: 1961600, + flag: 'https://restcountries.eu/data/lva.svg', + currency: 'Euro' + }, + { + name: 'Lebanon', + capital: 'Beirut', + languages: ['Arabic', 'French'], + population: 5988000, + flag: 'https://restcountries.eu/data/lbn.svg', + currency: 'Lebanese pound' + }, + { + name: 'Lesotho', + capital: 'Maseru', + languages: ['English', 'Southern Sotho'], + population: 1894194, + flag: 'https://restcountries.eu/data/lso.svg', + currency: 'Lesotho loti' + }, + { + name: 'Liberia', + capital: 'Monrovia', + languages: ['English'], + population: 4615000, + flag: 'https://restcountries.eu/data/lbr.svg', + currency: 'Liberian dollar' + }, + { + name: 'Libya', + capital: 'Tripoli', + languages: ['Arabic'], + population: 6385000, + flag: 'https://restcountries.eu/data/lby.svg', + currency: 'Libyan dinar' + }, + { + name: 'Liechtenstein', + capital: 'Vaduz', + languages: ['German'], + population: 37623, + flag: 'https://restcountries.eu/data/lie.svg', + currency: 'Swiss franc' + }, + { + name: 'Lithuania', + capital: 'Vilnius', + languages: ['Lithuanian'], + population: 2872294, + flag: 'https://restcountries.eu/data/ltu.svg', + currency: 'Euro' + }, + { + name: 'Luxembourg', + capital: 'Luxembourg', + languages: ['French', 'German', 'Luxembourgish'], + population: 576200, + flag: 'https://restcountries.eu/data/lux.svg', + currency: 'Euro' + }, + { + name: 'Macao', + capital: '', + languages: ['Chinese', 'Portuguese'], + population: 649100, + flag: 'https://restcountries.eu/data/mac.svg', + currency: 'Macanese pataca' + }, + { + name: 'Macedonia (the former Yugoslav Republic of)', + capital: 'Skopje', + languages: ['Macedonian'], + population: 2058539, + flag: 'https://restcountries.eu/data/mkd.svg', + currency: 'Macedonian denar' + }, + { + name: 'Madagascar', + capital: 'Antananarivo', + languages: ['French', 'Malagasy'], + population: 22434363, + flag: 'https://restcountries.eu/data/mdg.svg', + currency: 'Malagasy ariary' + }, + { + name: 'Malawi', + capital: 'Lilongwe', + languages: ['English', 'Chichewa'], + population: 16832910, + flag: 'https://restcountries.eu/data/mwi.svg', + currency: 'Malawian kwacha' + }, + { + name: 'Malaysia', + capital: 'Kuala Lumpur', + languages: ['Malaysian'], + population: 31405416, + flag: 'https://restcountries.eu/data/mys.svg', + currency: 'Malaysian ringgit' + }, + { + name: 'Maldives', + capital: 'Malé', + languages: ['Divehi'], + population: 344023, + flag: 'https://restcountries.eu/data/mdv.svg', + currency: 'Maldivian rufiyaa' + }, + { + name: 'Mali', + capital: 'Bamako', + languages: ['French'], + population: 18135000, + flag: 'https://restcountries.eu/data/mli.svg', + currency: 'West African CFA franc' + }, + { + name: 'Malta', + capital: 'Valletta', + languages: ['Maltese', 'English'], + population: 425384, + flag: 'https://restcountries.eu/data/mlt.svg', + currency: 'Euro' + }, + { + name: 'Marshall Islands', + capital: 'Majuro', + languages: ['English', 'Marshallese'], + population: 54880, + flag: 'https://restcountries.eu/data/mhl.svg', + currency: 'United States dollar' + }, + { + name: 'Martinique', + capital: 'Fort-de-France', + languages: ['French'], + population: 378243, + flag: 'https://restcountries.eu/data/mtq.svg', + currency: 'Euro' + }, + { + name: 'Mauritania', + capital: 'Nouakchott', + languages: ['Arabic'], + population: 3718678, + flag: 'https://restcountries.eu/data/mrt.svg', + currency: 'Mauritanian ouguiya' + }, + { + name: 'Mauritius', + capital: 'Port Louis', + languages: ['English'], + population: 1262879, + flag: 'https://restcountries.eu/data/mus.svg', + currency: 'Mauritian rupee' + }, + { + name: 'Mayotte', + capital: 'Mamoudzou', + languages: ['French'], + population: 226915, + flag: 'https://restcountries.eu/data/myt.svg', + currency: 'Euro' + }, + { + name: 'Mexico', + capital: 'Mexico City', + languages: ['Spanish'], + population: 122273473, + flag: 'https://restcountries.eu/data/mex.svg', + currency: 'Mexican peso' + }, + { + name: 'Micronesia (Federated States of)', + capital: 'Palikir', + languages: ['English'], + population: 102800, + flag: 'https://restcountries.eu/data/fsm.svg', + currency: '[D]' + }, + { + name: 'Moldova (Republic of)', + capital: 'Chișinău', + languages: ['Romanian'], + population: 3553100, + flag: 'https://restcountries.eu/data/mda.svg', + currency: 'Moldovan leu' + }, + { + name: 'Monaco', + capital: 'Monaco', + languages: ['French'], + population: 38400, + flag: 'https://restcountries.eu/data/mco.svg', + currency: 'Euro' + }, + { + name: 'Mongolia', + capital: 'Ulan Bator', + languages: ['Mongolian'], + population: 3093100, + flag: 'https://restcountries.eu/data/mng.svg', + currency: 'Mongolian tögrög' + }, + { + name: 'Montenegro', + capital: 'Podgorica', + languages: ['Serbian', 'Bosnian', 'Albanian', 'Croatian'], + population: 621810, + flag: 'https://restcountries.eu/data/mne.svg', + currency: 'Euro' + }, + { + name: 'Montserrat', + capital: 'Plymouth', + languages: ['English'], + population: 4922, + flag: 'https://restcountries.eu/data/msr.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Morocco', + capital: 'Rabat', + languages: ['Arabic'], + population: 33337529, + flag: 'https://restcountries.eu/data/mar.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Mozambique', + capital: 'Maputo', + languages: ['Portuguese'], + population: 26423700, + flag: 'https://restcountries.eu/data/moz.svg', + currency: 'Mozambican metical' + }, + { + name: 'Myanmar', + capital: 'Naypyidaw', + languages: ['Burmese'], + population: 51419420, + flag: 'https://restcountries.eu/data/mmr.svg', + currency: 'Burmese kyat' + }, + { + name: 'Namibia', + capital: 'Windhoek', + languages: ['English', 'Afrikaans'], + population: 2324388, + flag: 'https://restcountries.eu/data/nam.svg', + currency: 'Namibian dollar' + }, + { + name: 'Nauru', + capital: 'Yaren', + languages: ['English', 'Nauruan'], + population: 10084, + flag: 'https://restcountries.eu/data/nru.svg', + currency: 'Australian dollar' + }, + { + name: 'Nepal', + capital: 'Kathmandu', + languages: ['Nepali'], + population: 28431500, + flag: 'https://restcountries.eu/data/npl.svg', + currency: 'Nepalese rupee' + }, + { + name: 'Netherlands', + capital: 'Amsterdam', + languages: ['Dutch'], + population: 17019800, + flag: 'https://restcountries.eu/data/nld.svg', + currency: 'Euro' + }, + { + name: 'New Caledonia', + capital: 'Nouméa', + languages: ['French'], + population: 268767, + flag: 'https://restcountries.eu/data/ncl.svg', + currency: 'CFP franc' + }, + { + name: 'New Zealand', + capital: 'Wellington', + languages: ['English', 'Māori'], + population: 4697854, + flag: 'https://restcountries.eu/data/nzl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Nicaragua', + capital: 'Managua', + languages: ['Spanish'], + population: 6262703, + flag: 'https://restcountries.eu/data/nic.svg', + currency: 'Nicaraguan córdoba' + }, + { + name: 'Niger', + capital: 'Niamey', + languages: ['French'], + population: 20715000, + flag: 'https://restcountries.eu/data/ner.svg', + currency: 'West African CFA franc' + }, + { + name: 'Nigeria', + capital: 'Abuja', + languages: ['English'], + population: 186988000, + flag: 'https://restcountries.eu/data/nga.svg', + currency: 'Nigerian naira' + }, + { + name: 'Niue', + capital: 'Alofi', + languages: ['English'], + population: 1470, + flag: 'https://restcountries.eu/data/niu.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Norfolk Island', + capital: 'Kingston', + languages: ['English'], + population: 2302, + flag: 'https://restcountries.eu/data/nfk.svg', + currency: 'Australian dollar' + }, + { + name: "Korea (Democratic People's Republic of)", + capital: 'Pyongyang', + languages: ['Korean'], + population: 25281000, + flag: 'https://restcountries.eu/data/prk.svg', + currency: 'North Korean won' + }, + { + name: 'Northern Mariana Islands', + capital: 'Saipan', + languages: ['English', 'Chamorro'], + population: 56940, + flag: 'https://restcountries.eu/data/mnp.svg', + currency: 'United States dollar' + }, + { + name: 'Norway', + capital: 'Oslo', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 5223256, + flag: 'https://restcountries.eu/data/nor.svg', + currency: 'Norwegian krone' + }, + { + name: 'Oman', + capital: 'Muscat', + languages: ['Arabic'], + population: 4420133, + flag: 'https://restcountries.eu/data/omn.svg', + currency: 'Omani rial' + }, + { + name: 'Pakistan', + capital: 'Islamabad', + languages: ['English', 'Urdu'], + population: 194125062, + flag: 'https://restcountries.eu/data/pak.svg', + currency: 'Pakistani rupee' + }, + { + name: 'Palau', + capital: 'Ngerulmud', + languages: ['English'], + population: 17950, + flag: 'https://restcountries.eu/data/plw.svg', + currency: '[E]' + }, + { + name: 'Palestine, State of', + capital: 'Ramallah', + languages: ['Arabic'], + population: 4682467, + flag: 'https://restcountries.eu/data/pse.svg', + currency: 'Israeli new sheqel' + }, + { + name: 'Panama', + capital: 'Panama City', + languages: ['Spanish'], + population: 3814672, + flag: 'https://restcountries.eu/data/pan.svg', + currency: 'Panamanian balboa' + }, + { + name: 'Papua New Guinea', + capital: 'Port Moresby', + languages: ['English'], + population: 8083700, + flag: 'https://restcountries.eu/data/png.svg', + currency: 'Papua New Guinean kina' + }, + { + name: 'Paraguay', + capital: 'Asunción', + languages: ['Spanish', 'Guaraní'], + population: 6854536, + flag: 'https://restcountries.eu/data/pry.svg', + currency: 'Paraguayan guaraní' + }, + { + name: 'Peru', + capital: 'Lima', + languages: ['Spanish'], + population: 31488700, + flag: 'https://restcountries.eu/data/per.svg', + currency: 'Peruvian sol' + }, + { + name: 'Philippines', + capital: 'Manila', + languages: ['English'], + population: 103279800, + flag: 'https://restcountries.eu/data/phl.svg', + currency: 'Philippine peso' + }, + { + name: 'Pitcairn', + capital: 'Adamstown', + languages: ['English'], + population: 56, + flag: 'https://restcountries.eu/data/pcn.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Poland', + capital: 'Warsaw', + languages: ['Polish'], + population: 38437239, + flag: 'https://restcountries.eu/data/pol.svg', + currency: 'Polish złoty' + }, + { + name: 'Portugal', + capital: 'Lisbon', + languages: ['Portuguese'], + population: 10374822, + flag: 'https://restcountries.eu/data/prt.svg', + currency: 'Euro' + }, + { + name: 'Puerto Rico', + capital: 'San Juan', + languages: ['Spanish', 'English'], + population: 3474182, + flag: 'https://restcountries.eu/data/pri.svg', + currency: 'United States dollar' + }, + { + name: 'Qatar', + capital: 'Doha', + languages: ['Arabic'], + population: 2587564, + flag: 'https://restcountries.eu/data/qat.svg', + currency: 'Qatari riyal' + }, + { + name: 'Republic of Kosovo', + capital: 'Pristina', + languages: ['Albanian', 'Serbian'], + population: 1733842, + flag: 'https://restcountries.eu/data/kos.svg', + currency: 'Euro' + }, + { + name: 'Réunion', + capital: 'Saint-Denis', + languages: ['French'], + population: 840974, + flag: 'https://restcountries.eu/data/reu.svg', + currency: 'Euro' + }, + { + name: 'Romania', + capital: 'Bucharest', + languages: ['Romanian'], + population: 19861408, + flag: 'https://restcountries.eu/data/rou.svg', + currency: 'Romanian leu' + }, + { + name: 'Russian Federation', + capital: 'Moscow', + languages: ['Russian'], + population: 146599183, + flag: 'https://restcountries.eu/data/rus.svg', + currency: 'Russian ruble' + }, + { + name: 'Rwanda', + capital: 'Kigali', + languages: ['Kinyarwanda', 'English', 'French'], + population: 11553188, + flag: 'https://restcountries.eu/data/rwa.svg', + currency: 'Rwandan franc' + }, + { + name: 'Saint Barthélemy', + capital: 'Gustavia', + languages: ['French'], + population: 9417, + flag: 'https://restcountries.eu/data/blm.svg', + currency: 'Euro' + }, + { + name: 'Saint Helena, Ascension and Tristan da Cunha', + capital: 'Jamestown', + languages: ['English'], + population: 4255, + flag: 'https://restcountries.eu/data/shn.svg', + currency: 'Saint Helena pound' + }, + { + name: 'Saint Kitts and Nevis', + capital: 'Basseterre', + languages: ['English'], + population: 46204, + flag: 'https://restcountries.eu/data/kna.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Lucia', + capital: 'Castries', + languages: ['English'], + population: 186000, + flag: 'https://restcountries.eu/data/lca.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Martin (French part)', + capital: 'Marigot', + languages: ['English', 'French', 'Dutch'], + population: 36979, + flag: 'https://restcountries.eu/data/maf.svg', + currency: 'Euro' + }, + { + name: 'Saint Pierre and Miquelon', + capital: 'Saint-Pierre', + languages: ['French'], + population: 6069, + flag: 'https://restcountries.eu/data/spm.svg', + currency: 'Euro' + }, + { + name: 'Saint Vincent and the Grenadines', + capital: 'Kingstown', + languages: ['English'], + population: 109991, + flag: 'https://restcountries.eu/data/vct.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Samoa', + capital: 'Apia', + languages: ['Samoan', 'English'], + population: 194899, + flag: 'https://restcountries.eu/data/wsm.svg', + currency: 'Samoan tālā' + }, + { + name: 'San Marino', + capital: 'City of San Marino', + languages: ['Italian'], + population: 33005, + flag: 'https://restcountries.eu/data/smr.svg', + currency: 'Euro' + }, + { + name: 'Sao Tome and Principe', + capital: 'São Tomé', + languages: ['Portuguese'], + population: 187356, + flag: 'https://restcountries.eu/data/stp.svg', + currency: 'São Tomé and Príncipe dobra' + }, + { + name: 'Saudi Arabia', + capital: 'Riyadh', + languages: ['Arabic'], + population: 32248200, + flag: 'https://restcountries.eu/data/sau.svg', + currency: 'Saudi riyal' + }, + { + name: 'Senegal', + capital: 'Dakar', + languages: ['French'], + population: 14799859, + flag: 'https://restcountries.eu/data/sen.svg', + currency: 'West African CFA franc' + }, + { + name: 'Serbia', + capital: 'Belgrade', + languages: ['Serbian'], + population: 7076372, + flag: 'https://restcountries.eu/data/srb.svg', + currency: 'Serbian dinar' + }, + { + name: 'Seychelles', + capital: 'Victoria', + languages: ['French', 'English'], + population: 91400, + flag: 'https://restcountries.eu/data/syc.svg', + currency: 'Seychellois rupee' + }, + { + name: 'Sierra Leone', + capital: 'Freetown', + languages: ['English'], + population: 7075641, + flag: 'https://restcountries.eu/data/sle.svg', + currency: 'Sierra Leonean leone' + }, + { + name: 'Singapore', + capital: 'Singapore', + languages: ['English', 'Malay', 'Tamil', 'Chinese'], + population: 5535000, + flag: 'https://restcountries.eu/data/sgp.svg', + currency: 'Brunei dollar' + }, + { + name: 'Sint Maarten (Dutch part)', + capital: 'Philipsburg', + languages: ['Dutch', 'English'], + population: 38247, + flag: 'https://restcountries.eu/data/sxm.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Slovakia', + capital: 'Bratislava', + languages: ['Slovak'], + population: 5426252, + flag: 'https://restcountries.eu/data/svk.svg', + currency: 'Euro' + }, + { + name: 'Slovenia', + capital: 'Ljubljana', + languages: ['Slovene'], + population: 2064188, + flag: 'https://restcountries.eu/data/svn.svg', + currency: 'Euro' + }, + { + name: 'Solomon Islands', + capital: 'Honiara', + languages: ['English'], + population: 642000, + flag: 'https://restcountries.eu/data/slb.svg', + currency: 'Solomon Islands dollar' + }, + { + name: 'Somalia', + capital: 'Mogadishu', + languages: ['Somali', 'Arabic'], + population: 11079000, + flag: 'https://restcountries.eu/data/som.svg', + currency: 'Somali shilling' + }, + { + name: 'South Africa', + capital: 'Pretoria', + languages: [ + 'Afrikaans', + 'English', + 'Southern Ndebele', + 'Southern Sotho', + 'Swati', + 'Tswana', + 'Tsonga', + 'Venda', + 'Xhosa', + 'Zulu' + ], + population: 55653654, + flag: 'https://restcountries.eu/data/zaf.svg', + currency: 'South African rand' + }, + { + name: 'South Georgia and the South Sandwich Islands', + capital: 'King Edward Point', + languages: ['English'], + population: 30, + flag: 'https://restcountries.eu/data/sgs.svg', + currency: 'British pound' + }, + { + name: 'Korea (Republic of)', + capital: 'Seoul', + languages: ['Korean'], + population: 50801405, + flag: 'https://restcountries.eu/data/kor.svg', + currency: 'South Korean won' + }, + { + name: 'South Sudan', + capital: 'Juba', + languages: ['English'], + population: 12131000, + flag: 'https://restcountries.eu/data/ssd.svg', + currency: 'South Sudanese pound' + }, + { + name: 'Spain', + capital: 'Madrid', + languages: ['Spanish'], + population: 46438422, + flag: 'https://restcountries.eu/data/esp.svg', + currency: 'Euro' + }, + { + name: 'Sri Lanka', + capital: 'Colombo', + languages: ['Sinhalese', 'Tamil'], + population: 20966000, + flag: 'https://restcountries.eu/data/lka.svg', + currency: 'Sri Lankan rupee' + }, + { + name: 'Sudan', + capital: 'Khartoum', + languages: ['Arabic', 'English'], + population: 39598700, + flag: 'https://restcountries.eu/data/sdn.svg', + currency: 'Sudanese pound' + }, + { + name: 'Suriname', + capital: 'Paramaribo', + languages: ['Dutch'], + population: 541638, + flag: 'https://restcountries.eu/data/sur.svg', + currency: 'Surinamese dollar' + }, + { + name: 'Svalbard and Jan Mayen', + capital: 'Longyearbyen', + languages: ['Norwegian'], + population: 2562, + flag: 'https://restcountries.eu/data/sjm.svg', + currency: 'Norwegian krone' + }, + { + name: 'Swaziland', + capital: 'Lobamba', + languages: ['English', 'Swati'], + population: 1132657, + flag: 'https://restcountries.eu/data/swz.svg', + currency: 'Swazi lilangeni' + }, + { + name: 'Sweden', + capital: 'Stockholm', + languages: ['Swedish'], + population: 9894888, + flag: 'https://restcountries.eu/data/swe.svg', + currency: 'Swedish krona' + }, + { + name: 'Switzerland', + capital: 'Bern', + languages: ['German', 'French', 'Italian'], + population: 8341600, + flag: 'https://restcountries.eu/data/che.svg', + currency: 'Swiss franc' + }, + { + name: 'Syrian Arab Republic', + capital: 'Damascus', + languages: ['Arabic'], + population: 18564000, + flag: 'https://restcountries.eu/data/syr.svg', + currency: 'Syrian pound' + }, + { + name: 'Taiwan', + capital: 'Taipei', + languages: ['Chinese'], + population: 23503349, + flag: 'https://restcountries.eu/data/twn.svg', + currency: 'New Taiwan dollar' + }, + { + name: 'Tajikistan', + capital: 'Dushanbe', + languages: ['Tajik', 'Russian'], + population: 8593600, + flag: 'https://restcountries.eu/data/tjk.svg', + currency: 'Tajikistani somoni' + }, + { + name: 'Tanzania, United Republic of', + capital: 'Dodoma', + languages: ['Swahili', 'English'], + population: 55155000, + flag: 'https://restcountries.eu/data/tza.svg', + currency: 'Tanzanian shilling' + }, + { + name: 'Thailand', + capital: 'Bangkok', + languages: ['Thai'], + population: 65327652, + flag: 'https://restcountries.eu/data/tha.svg', + currency: 'Thai baht' + }, + { + name: 'Timor-Leste', + capital: 'Dili', + languages: ['Portuguese'], + population: 1167242, + flag: 'https://restcountries.eu/data/tls.svg', + currency: 'United States dollar' + }, + { + name: 'Togo', + capital: 'Lomé', + languages: ['French'], + population: 7143000, + flag: 'https://restcountries.eu/data/tgo.svg', + currency: 'West African CFA franc' + }, + { + name: 'Tokelau', + capital: 'Fakaofo', + languages: ['English'], + population: 1411, + flag: 'https://restcountries.eu/data/tkl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Tonga', + capital: "Nuku'alofa", + languages: ['English', 'Tonga (Tonga Islands)'], + population: 103252, + flag: 'https://restcountries.eu/data/ton.svg', + currency: 'Tongan paʻanga' + }, + { + name: 'Trinidad and Tobago', + capital: 'Port of Spain', + languages: ['English'], + population: 1349667, + flag: 'https://restcountries.eu/data/tto.svg', + currency: 'Trinidad and Tobago dollar' + }, + { + name: 'Tunisia', + capital: 'Tunis', + languages: ['Arabic'], + population: 11154400, + flag: 'https://restcountries.eu/data/tun.svg', + currency: 'Tunisian dinar' + }, + { + name: 'Turkey', + capital: 'Ankara', + languages: ['Turkish'], + population: 78741053, + flag: 'https://restcountries.eu/data/tur.svg', + currency: 'Turkish lira' + }, + { + name: 'Turkmenistan', + capital: 'Ashgabat', + languages: ['Turkmen', 'Russian'], + population: 4751120, + flag: 'https://restcountries.eu/data/tkm.svg', + currency: 'Turkmenistan manat' + }, + { + name: 'Turks and Caicos Islands', + capital: 'Cockburn Town', + languages: ['English'], + population: 31458, + flag: 'https://restcountries.eu/data/tca.svg', + currency: 'United States dollar' + }, + { + name: 'Tuvalu', + capital: 'Funafuti', + languages: ['English'], + population: 10640, + flag: 'https://restcountries.eu/data/tuv.svg', + currency: 'Australian dollar' + }, + { + name: 'Uganda', + capital: 'Kampala', + languages: ['English', 'Swahili'], + population: 33860700, + flag: 'https://restcountries.eu/data/uga.svg', + currency: 'Ugandan shilling' + }, + { + name: 'Ukraine', + capital: 'Kiev', + languages: ['Ukrainian'], + population: 42692393, + flag: 'https://restcountries.eu/data/ukr.svg', + currency: 'Ukrainian hryvnia' + }, + { + name: 'United Arab Emirates', + capital: 'Abu Dhabi', + languages: ['Arabic'], + population: 9856000, + flag: 'https://restcountries.eu/data/are.svg', + currency: 'United Arab Emirates dirham' + }, + { + name: 'United Kingdom of Great Britain and Northern Ireland', + capital: 'London', + languages: ['English'], + population: 65110000, + flag: 'https://restcountries.eu/data/gbr.svg', + currency: 'British pound' + }, + { + name: 'United States of America', + capital: 'Washington, D.C.', + languages: ['English'], + population: 323947000, + flag: 'https://restcountries.eu/data/usa.svg', + currency: 'United States dollar' + }, + { + name: 'Uruguay', + capital: 'Montevideo', + languages: ['Spanish'], + population: 3480222, + flag: 'https://restcountries.eu/data/ury.svg', + currency: 'Uruguayan peso' + }, + { + name: 'Uzbekistan', + capital: 'Tashkent', + languages: ['Uzbek', 'Russian'], + population: 31576400, + flag: 'https://restcountries.eu/data/uzb.svg', + currency: "Uzbekistani so'm" + }, + { + name: 'Vanuatu', + capital: 'Port Vila', + languages: ['Bislama', 'English', 'French'], + population: 277500, + flag: 'https://restcountries.eu/data/vut.svg', + currency: 'Vanuatu vatu' + }, + { + name: 'Venezuela (Bolivarian Republic of)', + capital: 'Caracas', + languages: ['Spanish'], + population: 31028700, + flag: 'https://restcountries.eu/data/ven.svg', + currency: 'Venezuelan bolívar' + }, + { + name: 'Viet Nam', + capital: 'Hanoi', + languages: ['Vietnamese'], + population: 92700000, + flag: 'https://restcountries.eu/data/vnm.svg', + currency: 'Vietnamese đồng' + }, + { + name: 'Wallis and Futuna', + capital: 'Mata-Utu', + languages: ['French'], + population: 11750, + flag: 'https://restcountries.eu/data/wlf.svg', + currency: 'CFP franc' + }, + { + name: 'Western Sahara', + capital: 'El Aaiún', + languages: ['Spanish'], + population: 510713, + flag: 'https://restcountries.eu/data/esh.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Yemen', + capital: "Sana'a", + languages: ['Arabic'], + population: 27478000, + flag: 'https://restcountries.eu/data/yem.svg', + currency: 'Yemeni rial' + }, + { + name: 'Zambia', + capital: 'Lusaka', + languages: ['English'], + population: 15933883, + flag: 'https://restcountries.eu/data/zmb.svg', + currency: 'Zambian kwacha' + }, + { + name: 'Zimbabwe', + capital: 'Harare', + languages: ['English', 'Shona', 'Northern Ndebele'], + population: 14240168, + flag: 'https://restcountries.eu/data/zwe.svg', + currency: 'Botswana pula' + } +] diff --git a/11_Day_Destructuring_and_spreading/11_day_starter/index.html b/11_Day_Destructuring_and_spreading/11_day_starter/index.html new file mode 100644 index 0000000..6efcab4 --- /dev/null +++ b/11_Day_Destructuring_and_spreading/11_day_starter/index.html @@ -0,0 +1,17 @@ + + + + + 30DaysOfJavaScript:11 Day + + + +

30DaysOfJavaScript:11 Day

+

Destructuring and Spread

+ + + + + + + \ No newline at end of file diff --git a/11_Day_Destructuring_and_spreading/11_day_starter/scripts/main.js b/11_Day_Destructuring_and_spreading/11_day_starter/scripts/main.js new file mode 100644 index 0000000..c6045c8 --- /dev/null +++ b/11_Day_Destructuring_and_spreading/11_day_starter/scripts/main.js @@ -0,0 +1,2 @@ +console.log(countries) +alert('Open the console and check if the countries has been loaded') \ No newline at end of file diff --git a/12_Day_Regular_expressions/12_day_regular_expressions.md b/12_Day_Regular_expressions/12_day_regular_expressions.md new file mode 100644 index 0000000..99d85f0 --- /dev/null +++ b/12_Day_Regular_expressions/12_day_regular_expressions.md @@ -0,0 +1,524 @@ +
+

30 Days Of JavaScript: Regular Expressions

+ + + + + Twitter Follow + + + Author: + Asabeneh Yetayeh
+ January, 2020 +
+
+ +[<< Day 11](../11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md) | [Day 13>>](../13_Day_Console_object_methods/13_day_console_object_methods.md) + +![Thirty Days Of JavaScript](../images/banners/day_1_12.png) + +- [📘 Day 12](#-day-12) + - [Regular Expressions](#regular-expressions) + - [RegExp parameters](#regexp-parameters) + - [Pattern](#pattern) + - [Flags](#flags) + - [Creating a pattern with RegExp Constructor](#creating-a-pattern-with-regexp-constructor) + - [Creating a pattern without RegExp Constructor](#creating-a-pattern-without-regexp-constructor) + - [RegExpp Object Methods](#regexpp-object-methods) + - [Testing for a match](#testing-for-a-match) + - [Array containing all of the match](#array-containing-all-of-the-match) + - [Replacing a substring](#replacing-a-substring) + - [Square Bracket](#square-bracket) + - [Escape character(\\) in RegExp](#escape-character-in-regexp) + - [One or more times(+)](#one-or-more-times) + - [Period(.)](#period) + - [Zero or more times(*)](#zero-or-more-times) + - [Zero or one times(?)](#zero-or-one-times) + - [Quantifier in RegExp](#quantifier-in-regexp) + - [Cart ^](#cart-) + - [Exact match](#exact-match) + - [💻 Exercises](#-exercises) + - [Exercises: Level 1](#exercises-level-1) + - [Exercises: Level 2](#exercises-level-2) + - [Exercises: Level 3](#exercises-level-3) + +# 📘 Day 12 + +## Regular Expressions + +A regular expression or RegExp is a small programming language that helps to find pattern in data. A RegExp can be used to check if some pattern exists in a different data types. To use RegExp in JavaScript either we use RegExp constructor or we can declare a RegExp pattern using two forward slashes followed by a flag. We can create a pattern in two ways. + +To declare a string we use a single quote, double quote a backtick to declare a regular expression we use two forward slashes and an optional flag. The flag could be g, i, m, s, u or y. + +### RegExp parameters + +A regular expression takes two parameters. One required search pattern and an optional flag. + +#### Pattern + +A pattern could be a text or any form of pattern which some sort of similarity. For instance the word spam in an email could be a pattern we are interested to look for in an email or a phone number format number might be our interest to look for. + +#### Flags + +Flags are optional parameters in a regular expression which determine the type of searching. Let see some of the flags: + +- g:is a global flag which means looking for a pattern in whole text +- i: case insensitive flag(it searches for both lowercase and uppercase) +- m: multiline + +### Creating a pattern with RegExp Constructor + +Declaring regular expression without global flag and case insensitive flag. + +```js +// without flag +let pattern = 'love' +let regEx = new RegExp(pattern) +``` + +Declaring regular expression with global flag and case insensitive flag. + +```js +let pattern = 'love' +let flag = 'gi' +let regEx = new RegExp(pattern, flag) +``` + +Declaring a regex pattern using RegExp object. Writing the pattern and the flag inside the RegExp constructor + +```js +let regEx = new RegExp('love','gi') +``` + +### Creating a pattern without RegExp Constructor + +Declaring regular expression with global flag and case insensitive flag. + +```js +let regEx= /love/gi +``` + +The above regular expression is the same as the one which we created with RegExp constructor + +```js +let regEx= new RegExp('love','gi') +``` + +### RegExpp Object Methods + +Let see some of RegExp methods + +#### Testing for a match + +*test()*:Tests for a match in a string. It returns true or false. + +```js +const str = 'I love JavaScript' +const pattern = /love/ +const result = pattern.test(str) +console.log(result) +``` + +```sh +true +``` + +#### Array containing all of the match + +*match()*:Returns an array containing all of the matches, including capturing groups, or null if no match is found. +If we do not use a global flag, match() returns an array containing the pattern, index, input and group. + +```js +const str = 'I love JavaScript' +const pattern = /love/ +const result = str.match(pattern) +console.log(result) +``` + +```sh +["love", index: 2, input: "I love JavaScript", groups: undefined] +``` + +```js +const str = 'I love JavaScript' +const pattern = /love/g +const result = str.match(pattern) +console.log(result) +``` + +```sh +["love"] +``` + +*search()*: Tests for a match in a string. It returns the index of the match, or -1 if the search fails. + +```js +const str = 'I love JavaScript' +const pattern = /love/g +const result = str.search(pattern) +console.log(result) +``` + +```sh +2 +``` + +#### Replacing a substring + +*replace()*: Executes a search for a match in a string, and replaces the matched substring with a replacement substring. + +```js +const txt = 'Python is the most beautiful language that a human begin has ever created.\ +I recommend python for a first programming language' + +matchReplaced = txt.replace(/Python|python/, 'JavaScript') +console.log(matchReplaced) +``` + +```sh +JavaScript is the most beautiful language that a human begin has ever created.I recommend python for a first programming language +``` + +```js +const txt = 'Python is the most beautiful language that a human begin has ever created.\ +I recommend python for a first programming language' + +matchReplaced = txt.replace(/Python|python/g, 'JavaScript') +console.log(matchReplaced) +``` + +```sh +JavaScript is the most beautiful language that a human begin has ever created.I recommend JavaScript for a first programming language +``` + +```js +const txt = 'Python is the most beautiful language that a human begin has ever created.\ +I recommend python for a first programming language' + +matchReplaced = txt.replace(/Python/gi, 'JavaScript') +console.log(matchReplaced) +``` + +```sh +JavaScript is the most beautiful language that a human begin has ever created.I recommend JavaScript for a first programming language +``` + +```js + +const txt = '%I a%m te%%a%%che%r% a%n%d %% I l%o%ve te%ach%ing.\ +T%he%re i%s n%o%th%ing as m%ore r%ewarding a%s e%duc%at%i%ng a%n%d e%m%p%ow%er%ing \ +p%e%o%ple.\ +I fo%und te%a%ching m%ore i%n%t%er%%es%ting t%h%an any other %jobs.\ +D%o%es thi%s m%ot%iv%a%te %y%o%u to b%e a t%e%a%cher.' + +matches = txt.replace(/%/g, '') +console.log(matches) +``` + +```sh +I am teacher and I love teaching.There is nothing as more rewarding as educating and empowering people.I found teaching more interesting than any other jobs.Does this motivate you to be a teacher. +``` + +* []: A set of characters + * [a-c] means, a or b or c + * [a-z] means, any letter a to z + * [A-Z] means, any character A to Z + * [0-3] means, 0 or 1 or 2 or 3 + * [0-9] means any number 0 to 9 + * [A-Za-z0-9] any character which is a to z, A to Z, 0 to 9 +* \\: uses to escape special characters + * \d mean:match where the string contains digits (numbers from 0-9) + * \D mean: match where the string does not contain digits +* . : any character except new line character(\n) +* ^: starts with + * r'^substring' eg r'^love', a sentence which starts with a word love + * r'[^abc] mean not a, not b, not c. +* $: ends with + * r'substring$' eg r'love$', sentence ends with a word love +* *: zero or more times + * r'[a]*' means a optional or it can be occur many times. +* +: one or more times + * r'[a]+' mean at least once or more times +* ?: zero or one times + * r'[a]?' mean zero times or once +* {3}: Exactly 3 characters +* {3,}: At least 3 character +* {3,8}: 3 to 8 characters +* |: Either or + * r'apple|banana' mean either of an apple or a banana +* (): Capture and group + +![Regular Expression cheat sheet](../images/regex.png) + +Let's use example to clarify the above meta characters + +### Square Bracket + +Let's use square bracket to include lower and upper case + +```js +const pattern = '[Aa]pple' // this square bracket mean either A or a +const txt = 'Apple and banana are fruits. An old cliche says an apple a day a doctor way has been replaced by a banana a day keeps the doctor far far away. ' +const matches = txt.match(pattern) + +console.log(matches) +``` + +```sh +["Apple", index: 0, input: "Apple and banana are fruits. An old cliche says an…by a banana a day keeps the doctor far far away. ", groups: undefined] + +``` + +```js +const pattern = /[Aa]pple/g // this square bracket mean either A or a +const txt = 'Apple and banana are fruits. An old cliche says an apple a day a doctor way has been replaced by a banana a day keeps the doctor far far away. ' +const matches = txt.match(pattern) + +console.log(matches) +``` + +```sh +["Apple", "apple"] +``` + +If we want to look for the banana, we write the pattern as follows: + +```js +const pattern = /[Aa]pple|[Bb]anana/g // this square bracket mean either A or a +const txt = 'Apple and banana are fruits. An old cliche says an apple a day a doctor way has been replaced by a banana a day keeps the doctor far far away. Banana is easy to eat too.' +const matches = txt.match(pattern) + +console.log(matches) +``` + +```sh +["Apple", "banana", "apple", "banana", "Banana"] +``` + +Using the square bracket and or operator , we manage to extract Apple, apple, Banana and banana. + +### Escape character(\\) in RegExp + +```js +const pattern = /\d/g // d is a special character which means digits +const txt = 'This regular expression example was made in January 12, 2020.' +const matches = txt. match(pattern) + +console.log(matches) // ["1", "2", "2", "0", "2", "0"], this is not what we want +``` + +```js +const pattern = /\d+/g // d is a special character which means digits +const txt = 'This regular expression example was made in January 12, 2020.' +const matches = txt. match(pattern) + +console.log(matches) // ["12", "2020"], this is not what we want +``` + +### One or more times(+) + +```js +const pattern = /\d+/g // d is a special character which means digits +const txt = 'This regular expression example was made in January 12, 2020.' +const matches = txt. match(pattern) +console.log(matches) // ["12", "2020"], this is not what we want +``` + +### Period(.) + +```js +const pattern = /[a]./g // this square bracket means a and . means any character except new line +const txt = 'Apple and banana are fruits' +const matches = txt.match(pattern) + +console.log(matches) // ["an", "an", "an", "a ", "ar"] +``` + +```js +const pattern = /[a].+/g // . any character, + any character one or more times +const txt = 'Apple and banana are fruits' +const matches = txt.match(pattern) + +console.log(matches) // ['and banana are fruits'] +``` + +### Zero or more times(*) + +Zero or many times. The pattern could may not occur or it can occur many times. + +```js + +const pattern = /[a].*/g //. any character, + any character one or more times +const txt = 'Apple and banana are fruits' +const matches = txt.match(pattern) + +console.log(matches) // ['and banana are fruits'] + +``` + +### Zero or one times(?) + +Zero or one times. The pattern could may not occur or it may occur once. + +```js +const txt = 'I am not sure if there is a convention how to write the word e-mail.\ +Some people write it email others may write it as Email or E-mail.' +const pattern = /[Ee]-?mail/g // ? means optional +matches = txt.match(pattern) + +console.log(matches) // ["e-mail", "email", "Email", "E-mail"] + +``` + +### Quantifier in RegExp + +We can specify the length of the substring we look for in a text, using a curly bracket. Lets imagine, we are interested in substring that their length are 4 characters + +```js +const txt = 'This regular expression example was made in December 6, 2019.' +const pattern = /\d{4}/g // exactly four times +const matches = txt.match(pattern) +console.log(matches) // ['2019'] +``` + +```js +const txt = 'This regular expression example was made in December 6, 2019.' +const pattern = /\d{1,4}/g // 1 to 4 +const matches = txt.match(pattern) +console.log(matches) // ['6', '2019'] +``` + +### Cart ^ + +- Starts with + +```js +const txt = 'This regular expression example was made in December 6, 2019.' +const pattern = /^This/ // ^ means starts with +const matches = txt.match(pattern) +console.log(matches) // ['This'] +``` + +- Negation + +```js +const txt = 'This regular expression example was made in December 6, 2019.' +const pattern = /[^A-Za-z,. ]+/g // ^ in set character means negation, not A to Z, not a to z, no space, no coma no period +const matches = txt.match(pattern) +console.log(matches) // ["6", "2019"] +``` + +### Exact match + +It should have ^ starting and $ which is an end. + +```js +let pattern = /^[A-Z][a-z]{3,12}$/; +let name = 'Asabeneh'; +let result = pattern.test(name) + +console.log(result) // true +``` + +🌕 You are going far. Keep going! Now, you are super charged with the power of regular expression. You have the power to extract and clean any kind of text and you can make meaning out of unstructured data. You have just completed day 12 challenges and you are 12 steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle. + +## 💻 Exercises + +### Exercises: Level 1 + +1. Calculate the total annual income of the person from the following text. ‘He earns 4000 euro from salary per month, 10000 euro annual bonus, 5500 euro online courses per month.’ +1. The position of some particles on the horizontal x-axis -12, -4, -3 and -1 in the negative direction, 0 at origin, 4 and 8 in the positive direction. Extract these numbers and find the distance between the two furthest particles. + +```js +points = ['-1', '2', '-4', '-3', '-1', '0', '4', '8'] +sortedPoints = [-4, -3, -1, -1, 0, 2, 4, 8] +distance = 12 +``` + +1. Write a pattern which identify if a string is a valid JavaScript variable + + ```sh + is_valid_variable('first_name') # True + is_valid_variable('first-name') # False + is_valid_variable('1first_name') # False + is_valid_variable('firstname') # True + ``` + +### Exercises: Level 2 + +1. Write a function called *tenMostFrequentWords* which get the ten most frequent word from a string? + + ```js + 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.` + console.log(tenMostFrequentWords(paragraph)) + ``` + + ```sh + [ + {word:'love', count:6}, + {word:'you', count:5}, + {word:'can', count:3}, + {word:'what', count:2}, + {word:'teaching', count:2}, + {word:'not', count:2}, + {word:'else', count:2}, + {word:'do', count:2}, + {word:'I', count:2}, + {word:'which', count:1}, + {word:'to', count:1}, + {word:'the', count:1}, + {word:'something', count:1}, + {word:'if', count:1}, + {word:'give', count:1}, + {word:'develop',count:1}, + {word:'capabilities',count:1}, + {word:'application', count:1}, + {word:'an',count:1}, + {word:'all',count:1}, + {word:'Python',count:1}, + {word:'If',count:1}] + ``` + + ```js + console.log(tenMostFrequentWords(paragraph, 10)) + ``` + + ```sh + [{word:'love', count:6}, + {word:'you', count:5}, + {word:'can', count:3}, + {word:'what', count:2}, + {word:'teaching', count:2}, + {word:'not', count:2}, + {word:'else', count:2}, + {word:'do', count:2}, + {word:'I', count:2}, + {word:'which', count:1} + ] + ``` + +### Exercises: Level 3 + +1. Writ a function which cleans text. Clean the following text. After cleaning, count three most frequent words in the string. + + ```js + sentence = `%I $am@% a %tea@cher%, &and& I lo%#ve %tea@ching%;. There $is nothing; &as& mo@re rewarding as educa@ting &and& @emp%o@wering peo@ple. ;I found tea@ching m%o@re interesting tha@n any other %jo@bs. %Do@es thi%s mo@tivate yo@u to be a tea@cher!?` + + console.log(cleanText(sentence)) + ``` + + ```sh + I am a teacher and I love teaching There is nothing as more rewarding as educating and empowering people I found teaching more interesting than any other jobs Does this motivate you to be a teacher + ``` +1. Write a function which find the most frequent words. After cleaning, count three most frequent words in the string. + + ```js + console.log(mostFrequentWords(cleanedText)) + [{word:'I', count:3}, {word:'teaching', count:2}, {word:'teacher', count:2}] + ``` + + +🎉 CONGRATULATIONS ! 🎉 + + +[<< Day 11](../11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md) | [Day 13>>](../13_Day_Console_object_methods/13_day_console_object_methods.md) diff --git a/12_Day_Regular_expressions/12_day_starter/data/countries_data.js b/12_Day_Regular_expressions/12_day_starter/data/countries_data.js new file mode 100644 index 0000000..92acddd --- /dev/null +++ b/12_Day_Regular_expressions/12_day_starter/data/countries_data.js @@ -0,0 +1,2013 @@ +const countries = [ + { + name: 'Afghanistan', + capital: 'Kabul', + languages: ['Pashto', 'Uzbek', 'Turkmen'], + population: 27657145, + flag: 'https://restcountries.eu/data/afg.svg', + currency: 'Afghan afghani' + }, + { + name: 'Åland Islands', + capital: 'Mariehamn', + languages: ['Swedish'], + population: 28875, + flag: 'https://restcountries.eu/data/ala.svg', + currency: 'Euro' + }, + { + name: 'Albania', + capital: 'Tirana', + languages: ['Albanian'], + population: 2886026, + flag: 'https://restcountries.eu/data/alb.svg', + currency: 'Albanian lek' + }, + { + name: 'Algeria', + capital: 'Algiers', + languages: ['Arabic'], + population: 40400000, + flag: 'https://restcountries.eu/data/dza.svg', + currency: 'Algerian dinar' + }, + { + name: 'American Samoa', + capital: 'Pago Pago', + languages: ['English', 'Samoan'], + population: 57100, + flag: 'https://restcountries.eu/data/asm.svg', + currency: 'United State Dollar' + }, + { + name: 'Andorra', + capital: 'Andorra la Vella', + languages: ['Catalan'], + population: 78014, + flag: 'https://restcountries.eu/data/and.svg', + currency: 'Euro' + }, + { + name: 'Angola', + capital: 'Luanda', + languages: ['Portuguese'], + population: 25868000, + flag: 'https://restcountries.eu/data/ago.svg', + currency: 'Angolan kwanza' + }, + { + name: 'Anguilla', + capital: 'The Valley', + languages: ['English'], + population: 13452, + flag: 'https://restcountries.eu/data/aia.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Antarctica', + capital: '', + languages: ['English', 'Russian'], + population: 1000, + flag: 'https://restcountries.eu/data/ata.svg', + currency: 'Australian dollar' + }, + { + name: 'Antigua and Barbuda', + capital: "Saint John's", + languages: ['English'], + population: 86295, + flag: 'https://restcountries.eu/data/atg.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Argentina', + capital: 'Buenos Aires', + languages: ['Spanish', 'Guaraní'], + population: 43590400, + flag: 'https://restcountries.eu/data/arg.svg', + currency: 'Argentine peso' + }, + { + name: 'Armenia', + capital: 'Yerevan', + languages: ['Armenian', 'Russian'], + population: 2994400, + flag: 'https://restcountries.eu/data/arm.svg', + currency: 'Armenian dram' + }, + { + name: 'Aruba', + capital: 'Oranjestad', + languages: ['Dutch', '(Eastern) Punjabi'], + population: 107394, + flag: 'https://restcountries.eu/data/abw.svg', + currency: 'Aruban florin' + }, + { + name: 'Australia', + capital: 'Canberra', + languages: ['English'], + population: 24117360, + flag: 'https://restcountries.eu/data/aus.svg', + currency: 'Australian dollar' + }, + { + name: 'Austria', + capital: 'Vienna', + languages: ['German'], + population: 8725931, + flag: 'https://restcountries.eu/data/aut.svg', + currency: 'Euro' + }, + { + name: 'Azerbaijan', + capital: 'Baku', + languages: ['Azerbaijani'], + population: 9730500, + flag: 'https://restcountries.eu/data/aze.svg', + currency: 'Azerbaijani manat' + }, + { + name: 'Bahamas', + capital: 'Nassau', + languages: ['English'], + population: 378040, + flag: 'https://restcountries.eu/data/bhs.svg', + currency: 'Bahamian dollar' + }, + { + name: 'Bahrain', + capital: 'Manama', + languages: ['Arabic'], + population: 1404900, + flag: 'https://restcountries.eu/data/bhr.svg', + currency: 'Bahraini dinar' + }, + { + name: 'Bangladesh', + capital: 'Dhaka', + languages: ['Bengali'], + population: 161006790, + flag: 'https://restcountries.eu/data/bgd.svg', + currency: 'Bangladeshi taka' + }, + { + name: 'Barbados', + capital: 'Bridgetown', + languages: ['English'], + population: 285000, + flag: 'https://restcountries.eu/data/brb.svg', + currency: 'Barbadian dollar' + }, + { + name: 'Belarus', + capital: 'Minsk', + languages: ['Belarusian', 'Russian'], + population: 9498700, + flag: 'https://restcountries.eu/data/blr.svg', + currency: 'New Belarusian ruble' + }, + { + name: 'Belgium', + capital: 'Brussels', + languages: ['Dutch', 'French', 'German'], + population: 11319511, + flag: 'https://restcountries.eu/data/bel.svg', + currency: 'Euro' + }, + { + name: 'Belize', + capital: 'Belmopan', + languages: ['English', 'Spanish'], + population: 370300, + flag: 'https://restcountries.eu/data/blz.svg', + currency: 'Belize dollar' + }, + { + name: 'Benin', + capital: 'Porto-Novo', + languages: ['French'], + population: 10653654, + flag: 'https://restcountries.eu/data/ben.svg', + currency: 'West African CFA franc' + }, + { + name: 'Bermuda', + capital: 'Hamilton', + languages: ['English'], + population: 61954, + flag: 'https://restcountries.eu/data/bmu.svg', + currency: 'Bermudian dollar' + }, + { + name: 'Bhutan', + capital: 'Thimphu', + languages: ['Dzongkha'], + population: 775620, + flag: 'https://restcountries.eu/data/btn.svg', + currency: 'Bhutanese ngultrum' + }, + { + name: 'Bolivia (Plurinational State of)', + capital: 'Sucre', + languages: ['Spanish', 'Aymara', 'Quechua'], + population: 10985059, + flag: 'https://restcountries.eu/data/bol.svg', + currency: 'Bolivian boliviano' + }, + { + name: 'Bonaire, Sint Eustatius and Saba', + capital: 'Kralendijk', + languages: ['Dutch'], + population: 17408, + flag: 'https://restcountries.eu/data/bes.svg', + currency: 'United States dollar' + }, + { + name: 'Bosnia and Herzegovina', + capital: 'Sarajevo', + languages: ['Bosnian', 'Croatian', 'Serbian'], + population: 3531159, + flag: 'https://restcountries.eu/data/bih.svg', + currency: 'Bosnia and Herzegovina convertible mark' + }, + { + name: 'Botswana', + capital: 'Gaborone', + languages: ['English', 'Tswana'], + population: 2141206, + flag: 'https://restcountries.eu/data/bwa.svg', + currency: 'Botswana pula' + }, + { + name: 'Bouvet Island', + capital: '', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 0, + flag: 'https://restcountries.eu/data/bvt.svg', + currency: 'Norwegian krone' + }, + { + name: 'Brazil', + capital: 'Brasília', + languages: ['Portuguese'], + population: 206135893, + flag: 'https://restcountries.eu/data/bra.svg', + currency: 'Brazilian real' + }, + { + name: 'British Indian Ocean Territory', + capital: 'Diego Garcia', + languages: ['English'], + population: 3000, + flag: 'https://restcountries.eu/data/iot.svg', + currency: 'United States dollar' + }, + { + name: 'United States Minor Outlying Islands', + capital: '', + languages: ['English'], + population: 300, + flag: 'https://restcountries.eu/data/umi.svg', + currency: 'United States Dollar' + }, + { + name: 'Virgin Islands (British)', + capital: 'Road Town', + languages: ['English'], + population: 28514, + flag: 'https://restcountries.eu/data/vgb.svg', + currency: '[D]' + }, + { + name: 'Virgin Islands (U.S.)', + capital: 'Charlotte Amalie', + languages: ['English'], + population: 114743, + flag: 'https://restcountries.eu/data/vir.svg', + currency: 'United States dollar' + }, + { + name: 'Brunei Darussalam', + capital: 'Bandar Seri Begawan', + languages: ['Malay'], + population: 411900, + flag: 'https://restcountries.eu/data/brn.svg', + currency: 'Brunei dollar' + }, + { + name: 'Bulgaria', + capital: 'Sofia', + languages: ['Bulgarian'], + population: 7153784, + flag: 'https://restcountries.eu/data/bgr.svg', + currency: 'Bulgarian lev' + }, + { + name: 'Burkina Faso', + capital: 'Ouagadougou', + languages: ['French', 'Fula'], + population: 19034397, + flag: 'https://restcountries.eu/data/bfa.svg', + currency: 'West African CFA franc' + }, + { + name: 'Burundi', + capital: 'Bujumbura', + languages: ['French', 'Kirundi'], + population: 10114505, + flag: 'https://restcountries.eu/data/bdi.svg', + currency: 'Burundian franc' + }, + { + name: 'Cambodia', + capital: 'Phnom Penh', + languages: ['Khmer'], + population: 15626444, + flag: 'https://restcountries.eu/data/khm.svg', + currency: 'Cambodian riel' + }, + { + name: 'Cameroon', + capital: 'Yaoundé', + languages: ['English', 'French'], + population: 22709892, + flag: 'https://restcountries.eu/data/cmr.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Canada', + capital: 'Ottawa', + languages: ['English', 'French'], + population: 36155487, + flag: 'https://restcountries.eu/data/can.svg', + currency: 'Canadian dollar' + }, + { + name: 'Cabo Verde', + capital: 'Praia', + languages: ['Portuguese'], + population: 531239, + flag: 'https://restcountries.eu/data/cpv.svg', + currency: 'Cape Verdean escudo' + }, + { + name: 'Cayman Islands', + capital: 'George Town', + languages: ['English'], + population: 58238, + flag: 'https://restcountries.eu/data/cym.svg', + currency: 'Cayman Islands dollar' + }, + { + name: 'Central African Republic', + capital: 'Bangui', + languages: ['French', 'Sango'], + population: 4998000, + flag: 'https://restcountries.eu/data/caf.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chad', + capital: "N'Djamena", + languages: ['French', 'Arabic'], + population: 14497000, + flag: 'https://restcountries.eu/data/tcd.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chile', + capital: 'Santiago', + languages: ['Spanish'], + population: 18191900, + flag: 'https://restcountries.eu/data/chl.svg', + currency: 'Chilean peso' + }, + { + name: 'China', + capital: 'Beijing', + languages: ['Chinese'], + population: 1377422166, + flag: 'https://restcountries.eu/data/chn.svg', + currency: 'Chinese yuan' + }, + { + name: 'Christmas Island', + capital: 'Flying Fish Cove', + languages: ['English'], + population: 2072, + flag: 'https://restcountries.eu/data/cxr.svg', + currency: 'Australian dollar' + }, + { + name: 'Cocos (Keeling) Islands', + capital: 'West Island', + languages: ['English'], + population: 550, + flag: 'https://restcountries.eu/data/cck.svg', + currency: 'Australian dollar' + }, + { + name: 'Colombia', + capital: 'Bogotá', + languages: ['Spanish'], + population: 48759958, + flag: 'https://restcountries.eu/data/col.svg', + currency: 'Colombian peso' + }, + { + name: 'Comoros', + capital: 'Moroni', + languages: ['Arabic', 'French'], + population: 806153, + flag: 'https://restcountries.eu/data/com.svg', + currency: 'Comorian franc' + }, + { + name: 'Congo', + capital: 'Brazzaville', + languages: ['French', 'Lingala'], + population: 4741000, + flag: 'https://restcountries.eu/data/cog.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Congo (Democratic Republic of the)', + capital: 'Kinshasa', + languages: ['French', 'Lingala', 'Kongo', 'Swahili', 'Luba-Katanga'], + population: 85026000, + flag: 'https://restcountries.eu/data/cod.svg', + currency: 'Congolese franc' + }, + { + name: 'Cook Islands', + capital: 'Avarua', + languages: ['English'], + population: 18100, + flag: 'https://restcountries.eu/data/cok.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Costa Rica', + capital: 'San José', + languages: ['Spanish'], + population: 4890379, + flag: 'https://restcountries.eu/data/cri.svg', + currency: 'Costa Rican colón' + }, + { + name: 'Croatia', + capital: 'Zagreb', + languages: ['Croatian'], + population: 4190669, + flag: 'https://restcountries.eu/data/hrv.svg', + currency: 'Croatian kuna' + }, + { + name: 'Cuba', + capital: 'Havana', + languages: ['Spanish'], + population: 11239004, + flag: 'https://restcountries.eu/data/cub.svg', + currency: 'Cuban convertible peso' + }, + { + name: 'Curaçao', + capital: 'Willemstad', + languages: ['Dutch', '(Eastern) Punjabi', 'English'], + population: 154843, + flag: 'https://restcountries.eu/data/cuw.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Cyprus', + capital: 'Nicosia', + languages: ['Greek (modern)', 'Turkish', 'Armenian'], + population: 847000, + flag: 'https://restcountries.eu/data/cyp.svg', + currency: 'Euro' + }, + { + name: 'Czech Republic', + capital: 'Prague', + languages: ['Czech', 'Slovak'], + population: 10558524, + flag: 'https://restcountries.eu/data/cze.svg', + currency: 'Czech koruna' + }, + { + name: 'Denmark', + capital: 'Copenhagen', + languages: ['Danish'], + population: 5717014, + flag: 'https://restcountries.eu/data/dnk.svg', + currency: 'Danish krone' + }, + { + name: 'Djibouti', + capital: 'Djibouti', + languages: ['French', 'Arabic'], + population: 900000, + flag: 'https://restcountries.eu/data/dji.svg', + currency: 'Djiboutian franc' + }, + { + name: 'Dominica', + capital: 'Roseau', + languages: ['English'], + population: 71293, + flag: 'https://restcountries.eu/data/dma.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Dominican Republic', + capital: 'Santo Domingo', + languages: ['Spanish'], + population: 10075045, + flag: 'https://restcountries.eu/data/dom.svg', + currency: 'Dominican peso' + }, + { + name: 'Ecuador', + capital: 'Quito', + languages: ['Spanish'], + population: 16545799, + flag: 'https://restcountries.eu/data/ecu.svg', + currency: 'United States dollar' + }, + { + name: 'Egypt', + capital: 'Cairo', + languages: ['Arabic'], + population: 91290000, + flag: 'https://restcountries.eu/data/egy.svg', + currency: 'Egyptian pound' + }, + { + name: 'El Salvador', + capital: 'San Salvador', + languages: ['Spanish'], + population: 6520675, + flag: 'https://restcountries.eu/data/slv.svg', + currency: 'United States dollar' + }, + { + name: 'Equatorial Guinea', + capital: 'Malabo', + languages: ['Spanish', 'French'], + population: 1222442, + flag: 'https://restcountries.eu/data/gnq.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Eritrea', + capital: 'Asmara', + languages: ['Tigrinya', 'Arabic', 'English'], + population: 5352000, + flag: 'https://restcountries.eu/data/eri.svg', + currency: 'Eritrean nakfa' + }, + { + name: 'Estonia', + capital: 'Tallinn', + languages: ['Estonian'], + population: 1315944, + flag: 'https://restcountries.eu/data/est.svg', + currency: 'Euro' + }, + { + name: 'Ethiopia', + capital: 'Addis Ababa', + languages: ['Amharic'], + population: 92206005, + flag: 'https://restcountries.eu/data/eth.svg', + currency: 'Ethiopian birr' + }, + { + name: 'Falkland Islands (Malvinas)', + capital: 'Stanley', + languages: ['English'], + population: 2563, + flag: 'https://restcountries.eu/data/flk.svg', + currency: 'Falkland Islands pound' + }, + { + name: 'Faroe Islands', + capital: 'Tórshavn', + languages: ['Faroese'], + population: 49376, + flag: 'https://restcountries.eu/data/fro.svg', + currency: 'Danish krone' + }, + { + name: 'Fiji', + capital: 'Suva', + languages: ['English', 'Fijian', 'Hindi', 'Urdu'], + population: 867000, + flag: 'https://restcountries.eu/data/fji.svg', + currency: 'Fijian dollar' + }, + { + name: 'Finland', + capital: 'Helsinki', + languages: ['Finnish', 'Swedish'], + population: 5491817, + flag: 'https://restcountries.eu/data/fin.svg', + currency: 'Euro' + }, + { + name: 'France', + capital: 'Paris', + languages: ['French'], + population: 66710000, + flag: 'https://restcountries.eu/data/fra.svg', + currency: 'Euro' + }, + { + name: 'French Guiana', + capital: 'Cayenne', + languages: ['French'], + population: 254541, + flag: 'https://restcountries.eu/data/guf.svg', + currency: 'Euro' + }, + { + name: 'French Polynesia', + capital: 'Papeetē', + languages: ['French'], + population: 271800, + flag: 'https://restcountries.eu/data/pyf.svg', + currency: 'CFP franc' + }, + { + name: 'French Southern Territories', + capital: 'Port-aux-Français', + languages: ['French'], + population: 140, + flag: 'https://restcountries.eu/data/atf.svg', + currency: 'Euro' + }, + { + name: 'Gabon', + capital: 'Libreville', + languages: ['French'], + population: 1802278, + flag: 'https://restcountries.eu/data/gab.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Gambia', + capital: 'Banjul', + languages: ['English'], + population: 1882450, + flag: 'https://restcountries.eu/data/gmb.svg', + currency: 'Gambian dalasi' + }, + { + name: 'Georgia', + capital: 'Tbilisi', + languages: ['Georgian'], + population: 3720400, + flag: 'https://restcountries.eu/data/geo.svg', + currency: 'Georgian Lari' + }, + { + name: 'Germany', + capital: 'Berlin', + languages: ['German'], + population: 81770900, + flag: 'https://restcountries.eu/data/deu.svg', + currency: 'Euro' + }, + { + name: 'Ghana', + capital: 'Accra', + languages: ['English'], + population: 27670174, + flag: 'https://restcountries.eu/data/gha.svg', + currency: 'Ghanaian cedi' + }, + { + name: 'Gibraltar', + capital: 'Gibraltar', + languages: ['English'], + population: 33140, + flag: 'https://restcountries.eu/data/gib.svg', + currency: 'Gibraltar pound' + }, + { + name: 'Greece', + capital: 'Athens', + languages: ['Greek (modern)'], + population: 10858018, + flag: 'https://restcountries.eu/data/grc.svg', + currency: 'Euro' + }, + { + name: 'Greenland', + capital: 'Nuuk', + languages: ['Kalaallisut'], + population: 55847, + flag: 'https://restcountries.eu/data/grl.svg', + currency: 'Danish krone' + }, + { + name: 'Grenada', + capital: "St. George's", + languages: ['English'], + population: 103328, + flag: 'https://restcountries.eu/data/grd.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Guadeloupe', + capital: 'Basse-Terre', + languages: ['French'], + population: 400132, + flag: 'https://restcountries.eu/data/glp.svg', + currency: 'Euro' + }, + { + name: 'Guam', + capital: 'Hagåtña', + languages: ['English', 'Chamorro', 'Spanish'], + population: 184200, + flag: 'https://restcountries.eu/data/gum.svg', + currency: 'United States dollar' + }, + { + name: 'Guatemala', + capital: 'Guatemala City', + languages: ['Spanish'], + population: 16176133, + flag: 'https://restcountries.eu/data/gtm.svg', + currency: 'Guatemalan quetzal' + }, + { + name: 'Guernsey', + capital: 'St. Peter Port', + languages: ['English', 'French'], + population: 62999, + flag: 'https://restcountries.eu/data/ggy.svg', + currency: 'British pound' + }, + { + name: 'Guinea', + capital: 'Conakry', + languages: ['French', 'Fula'], + population: 12947000, + flag: 'https://restcountries.eu/data/gin.svg', + currency: 'Guinean franc' + }, + { + name: 'Guinea-Bissau', + capital: 'Bissau', + languages: ['Portuguese'], + population: 1547777, + flag: 'https://restcountries.eu/data/gnb.svg', + currency: 'West African CFA franc' + }, + { + name: 'Guyana', + capital: 'Georgetown', + languages: ['English'], + population: 746900, + flag: 'https://restcountries.eu/data/guy.svg', + currency: 'Guyanese dollar' + }, + { + name: 'Haiti', + capital: 'Port-au-Prince', + languages: ['French', 'Haitian'], + population: 11078033, + flag: 'https://restcountries.eu/data/hti.svg', + currency: 'Haitian gourde' + }, + { + name: 'Heard Island and McDonald Islands', + capital: '', + languages: ['English'], + population: 0, + flag: 'https://restcountries.eu/data/hmd.svg', + currency: 'Australian dollar' + }, + { + name: 'Holy See', + capital: 'Rome', + languages: ['Latin', 'Italian', 'French', 'German'], + population: 451, + flag: 'https://restcountries.eu/data/vat.svg', + currency: 'Euro' + }, + { + name: 'Honduras', + capital: 'Tegucigalpa', + languages: ['Spanish'], + population: 8576532, + flag: 'https://restcountries.eu/data/hnd.svg', + currency: 'Honduran lempira' + }, + { + name: 'Hong Kong', + capital: 'City of Victoria', + languages: ['English', 'Chinese'], + population: 7324300, + flag: 'https://restcountries.eu/data/hkg.svg', + currency: 'Hong Kong dollar' + }, + { + name: 'Hungary', + capital: 'Budapest', + languages: ['Hungarian'], + population: 9823000, + flag: 'https://restcountries.eu/data/hun.svg', + currency: 'Hungarian forint' + }, + { + name: 'Iceland', + capital: 'Reykjavík', + languages: ['Icelandic'], + population: 334300, + flag: 'https://restcountries.eu/data/isl.svg', + currency: 'Icelandic króna' + }, + { + name: 'India', + capital: 'New Delhi', + languages: ['Hindi', 'English'], + population: 1295210000, + flag: 'https://restcountries.eu/data/ind.svg', + currency: 'Indian rupee' + }, + { + name: 'Indonesia', + capital: 'Jakarta', + languages: ['Indonesian'], + population: 258705000, + flag: 'https://restcountries.eu/data/idn.svg', + currency: 'Indonesian rupiah' + }, + { + name: "Côte d'Ivoire", + capital: 'Yamoussoukro', + languages: ['French'], + population: 22671331, + flag: 'https://restcountries.eu/data/civ.svg', + currency: 'West African CFA franc' + }, + { + name: 'Iran (Islamic Republic of)', + capital: 'Tehran', + languages: ['Persian (Farsi)'], + population: 79369900, + flag: 'https://restcountries.eu/data/irn.svg', + currency: 'Iranian rial' + }, + { + name: 'Iraq', + capital: 'Baghdad', + languages: ['Arabic', 'Kurdish'], + population: 37883543, + flag: 'https://restcountries.eu/data/irq.svg', + currency: 'Iraqi dinar' + }, + { + name: 'Ireland', + capital: 'Dublin', + languages: ['Irish', 'English'], + population: 6378000, + flag: 'https://restcountries.eu/data/irl.svg', + currency: 'Euro' + }, + { + name: 'Isle of Man', + capital: 'Douglas', + languages: ['English', 'Manx'], + population: 84497, + flag: 'https://restcountries.eu/data/imn.svg', + currency: 'British pound' + }, + { + name: 'Israel', + capital: 'Jerusalem', + languages: ['Hebrew (modern)', 'Arabic'], + population: 8527400, + flag: 'https://restcountries.eu/data/isr.svg', + currency: 'Israeli new shekel' + }, + { + name: 'Italy', + capital: 'Rome', + languages: ['Italian'], + population: 60665551, + flag: 'https://restcountries.eu/data/ita.svg', + currency: 'Euro' + }, + { + name: 'Jamaica', + capital: 'Kingston', + languages: ['English'], + population: 2723246, + flag: 'https://restcountries.eu/data/jam.svg', + currency: 'Jamaican dollar' + }, + { + name: 'Japan', + capital: 'Tokyo', + languages: ['Japanese'], + population: 126960000, + flag: 'https://restcountries.eu/data/jpn.svg', + currency: 'Japanese yen' + }, + { + name: 'Jersey', + capital: 'Saint Helier', + languages: ['English', 'French'], + population: 100800, + flag: 'https://restcountries.eu/data/jey.svg', + currency: 'British pound' + }, + { + name: 'Jordan', + capital: 'Amman', + languages: ['Arabic'], + population: 9531712, + flag: 'https://restcountries.eu/data/jor.svg', + currency: 'Jordanian dinar' + }, + { + name: 'Kazakhstan', + capital: 'Astana', + languages: ['Kazakh', 'Russian'], + population: 17753200, + flag: 'https://restcountries.eu/data/kaz.svg', + currency: 'Kazakhstani tenge' + }, + { + name: 'Kenya', + capital: 'Nairobi', + languages: ['English', 'Swahili'], + population: 47251000, + flag: 'https://restcountries.eu/data/ken.svg', + currency: 'Kenyan shilling' + }, + { + name: 'Kiribati', + capital: 'South Tarawa', + languages: ['English'], + population: 113400, + flag: 'https://restcountries.eu/data/kir.svg', + currency: 'Australian dollar' + }, + { + name: 'Kuwait', + capital: 'Kuwait City', + languages: ['Arabic'], + population: 4183658, + flag: 'https://restcountries.eu/data/kwt.svg', + currency: 'Kuwaiti dinar' + }, + { + name: 'Kyrgyzstan', + capital: 'Bishkek', + languages: ['Kyrgyz', 'Russian'], + population: 6047800, + flag: 'https://restcountries.eu/data/kgz.svg', + currency: 'Kyrgyzstani som' + }, + { + name: "Lao People's Democratic Republic", + capital: 'Vientiane', + languages: ['Lao'], + population: 6492400, + flag: 'https://restcountries.eu/data/lao.svg', + currency: 'Lao kip' + }, + { + name: 'Latvia', + capital: 'Riga', + languages: ['Latvian'], + population: 1961600, + flag: 'https://restcountries.eu/data/lva.svg', + currency: 'Euro' + }, + { + name: 'Lebanon', + capital: 'Beirut', + languages: ['Arabic', 'French'], + population: 5988000, + flag: 'https://restcountries.eu/data/lbn.svg', + currency: 'Lebanese pound' + }, + { + name: 'Lesotho', + capital: 'Maseru', + languages: ['English', 'Southern Sotho'], + population: 1894194, + flag: 'https://restcountries.eu/data/lso.svg', + currency: 'Lesotho loti' + }, + { + name: 'Liberia', + capital: 'Monrovia', + languages: ['English'], + population: 4615000, + flag: 'https://restcountries.eu/data/lbr.svg', + currency: 'Liberian dollar' + }, + { + name: 'Libya', + capital: 'Tripoli', + languages: ['Arabic'], + population: 6385000, + flag: 'https://restcountries.eu/data/lby.svg', + currency: 'Libyan dinar' + }, + { + name: 'Liechtenstein', + capital: 'Vaduz', + languages: ['German'], + population: 37623, + flag: 'https://restcountries.eu/data/lie.svg', + currency: 'Swiss franc' + }, + { + name: 'Lithuania', + capital: 'Vilnius', + languages: ['Lithuanian'], + population: 2872294, + flag: 'https://restcountries.eu/data/ltu.svg', + currency: 'Euro' + }, + { + name: 'Luxembourg', + capital: 'Luxembourg', + languages: ['French', 'German', 'Luxembourgish'], + population: 576200, + flag: 'https://restcountries.eu/data/lux.svg', + currency: 'Euro' + }, + { + name: 'Macao', + capital: '', + languages: ['Chinese', 'Portuguese'], + population: 649100, + flag: 'https://restcountries.eu/data/mac.svg', + currency: 'Macanese pataca' + }, + { + name: 'Macedonia (the former Yugoslav Republic of)', + capital: 'Skopje', + languages: ['Macedonian'], + population: 2058539, + flag: 'https://restcountries.eu/data/mkd.svg', + currency: 'Macedonian denar' + }, + { + name: 'Madagascar', + capital: 'Antananarivo', + languages: ['French', 'Malagasy'], + population: 22434363, + flag: 'https://restcountries.eu/data/mdg.svg', + currency: 'Malagasy ariary' + }, + { + name: 'Malawi', + capital: 'Lilongwe', + languages: ['English', 'Chichewa'], + population: 16832910, + flag: 'https://restcountries.eu/data/mwi.svg', + currency: 'Malawian kwacha' + }, + { + name: 'Malaysia', + capital: 'Kuala Lumpur', + languages: ['Malaysian'], + population: 31405416, + flag: 'https://restcountries.eu/data/mys.svg', + currency: 'Malaysian ringgit' + }, + { + name: 'Maldives', + capital: 'Malé', + languages: ['Divehi'], + population: 344023, + flag: 'https://restcountries.eu/data/mdv.svg', + currency: 'Maldivian rufiyaa' + }, + { + name: 'Mali', + capital: 'Bamako', + languages: ['French'], + population: 18135000, + flag: 'https://restcountries.eu/data/mli.svg', + currency: 'West African CFA franc' + }, + { + name: 'Malta', + capital: 'Valletta', + languages: ['Maltese', 'English'], + population: 425384, + flag: 'https://restcountries.eu/data/mlt.svg', + currency: 'Euro' + }, + { + name: 'Marshall Islands', + capital: 'Majuro', + languages: ['English', 'Marshallese'], + population: 54880, + flag: 'https://restcountries.eu/data/mhl.svg', + currency: 'United States dollar' + }, + { + name: 'Martinique', + capital: 'Fort-de-France', + languages: ['French'], + population: 378243, + flag: 'https://restcountries.eu/data/mtq.svg', + currency: 'Euro' + }, + { + name: 'Mauritania', + capital: 'Nouakchott', + languages: ['Arabic'], + population: 3718678, + flag: 'https://restcountries.eu/data/mrt.svg', + currency: 'Mauritanian ouguiya' + }, + { + name: 'Mauritius', + capital: 'Port Louis', + languages: ['English'], + population: 1262879, + flag: 'https://restcountries.eu/data/mus.svg', + currency: 'Mauritian rupee' + }, + { + name: 'Mayotte', + capital: 'Mamoudzou', + languages: ['French'], + population: 226915, + flag: 'https://restcountries.eu/data/myt.svg', + currency: 'Euro' + }, + { + name: 'Mexico', + capital: 'Mexico City', + languages: ['Spanish'], + population: 122273473, + flag: 'https://restcountries.eu/data/mex.svg', + currency: 'Mexican peso' + }, + { + name: 'Micronesia (Federated States of)', + capital: 'Palikir', + languages: ['English'], + population: 102800, + flag: 'https://restcountries.eu/data/fsm.svg', + currency: '[D]' + }, + { + name: 'Moldova (Republic of)', + capital: 'Chișinău', + languages: ['Romanian'], + population: 3553100, + flag: 'https://restcountries.eu/data/mda.svg', + currency: 'Moldovan leu' + }, + { + name: 'Monaco', + capital: 'Monaco', + languages: ['French'], + population: 38400, + flag: 'https://restcountries.eu/data/mco.svg', + currency: 'Euro' + }, + { + name: 'Mongolia', + capital: 'Ulan Bator', + languages: ['Mongolian'], + population: 3093100, + flag: 'https://restcountries.eu/data/mng.svg', + currency: 'Mongolian tögrög' + }, + { + name: 'Montenegro', + capital: 'Podgorica', + languages: ['Serbian', 'Bosnian', 'Albanian', 'Croatian'], + population: 621810, + flag: 'https://restcountries.eu/data/mne.svg', + currency: 'Euro' + }, + { + name: 'Montserrat', + capital: 'Plymouth', + languages: ['English'], + population: 4922, + flag: 'https://restcountries.eu/data/msr.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Morocco', + capital: 'Rabat', + languages: ['Arabic'], + population: 33337529, + flag: 'https://restcountries.eu/data/mar.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Mozambique', + capital: 'Maputo', + languages: ['Portuguese'], + population: 26423700, + flag: 'https://restcountries.eu/data/moz.svg', + currency: 'Mozambican metical' + }, + { + name: 'Myanmar', + capital: 'Naypyidaw', + languages: ['Burmese'], + population: 51419420, + flag: 'https://restcountries.eu/data/mmr.svg', + currency: 'Burmese kyat' + }, + { + name: 'Namibia', + capital: 'Windhoek', + languages: ['English', 'Afrikaans'], + population: 2324388, + flag: 'https://restcountries.eu/data/nam.svg', + currency: 'Namibian dollar' + }, + { + name: 'Nauru', + capital: 'Yaren', + languages: ['English', 'Nauruan'], + population: 10084, + flag: 'https://restcountries.eu/data/nru.svg', + currency: 'Australian dollar' + }, + { + name: 'Nepal', + capital: 'Kathmandu', + languages: ['Nepali'], + population: 28431500, + flag: 'https://restcountries.eu/data/npl.svg', + currency: 'Nepalese rupee' + }, + { + name: 'Netherlands', + capital: 'Amsterdam', + languages: ['Dutch'], + population: 17019800, + flag: 'https://restcountries.eu/data/nld.svg', + currency: 'Euro' + }, + { + name: 'New Caledonia', + capital: 'Nouméa', + languages: ['French'], + population: 268767, + flag: 'https://restcountries.eu/data/ncl.svg', + currency: 'CFP franc' + }, + { + name: 'New Zealand', + capital: 'Wellington', + languages: ['English', 'Māori'], + population: 4697854, + flag: 'https://restcountries.eu/data/nzl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Nicaragua', + capital: 'Managua', + languages: ['Spanish'], + population: 6262703, + flag: 'https://restcountries.eu/data/nic.svg', + currency: 'Nicaraguan córdoba' + }, + { + name: 'Niger', + capital: 'Niamey', + languages: ['French'], + population: 20715000, + flag: 'https://restcountries.eu/data/ner.svg', + currency: 'West African CFA franc' + }, + { + name: 'Nigeria', + capital: 'Abuja', + languages: ['English'], + population: 186988000, + flag: 'https://restcountries.eu/data/nga.svg', + currency: 'Nigerian naira' + }, + { + name: 'Niue', + capital: 'Alofi', + languages: ['English'], + population: 1470, + flag: 'https://restcountries.eu/data/niu.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Norfolk Island', + capital: 'Kingston', + languages: ['English'], + population: 2302, + flag: 'https://restcountries.eu/data/nfk.svg', + currency: 'Australian dollar' + }, + { + name: "Korea (Democratic People's Republic of)", + capital: 'Pyongyang', + languages: ['Korean'], + population: 25281000, + flag: 'https://restcountries.eu/data/prk.svg', + currency: 'North Korean won' + }, + { + name: 'Northern Mariana Islands', + capital: 'Saipan', + languages: ['English', 'Chamorro'], + population: 56940, + flag: 'https://restcountries.eu/data/mnp.svg', + currency: 'United States dollar' + }, + { + name: 'Norway', + capital: 'Oslo', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 5223256, + flag: 'https://restcountries.eu/data/nor.svg', + currency: 'Norwegian krone' + }, + { + name: 'Oman', + capital: 'Muscat', + languages: ['Arabic'], + population: 4420133, + flag: 'https://restcountries.eu/data/omn.svg', + currency: 'Omani rial' + }, + { + name: 'Pakistan', + capital: 'Islamabad', + languages: ['English', 'Urdu'], + population: 194125062, + flag: 'https://restcountries.eu/data/pak.svg', + currency: 'Pakistani rupee' + }, + { + name: 'Palau', + capital: 'Ngerulmud', + languages: ['English'], + population: 17950, + flag: 'https://restcountries.eu/data/plw.svg', + currency: '[E]' + }, + { + name: 'Palestine, State of', + capital: 'Ramallah', + languages: ['Arabic'], + population: 4682467, + flag: 'https://restcountries.eu/data/pse.svg', + currency: 'Israeli new sheqel' + }, + { + name: 'Panama', + capital: 'Panama City', + languages: ['Spanish'], + population: 3814672, + flag: 'https://restcountries.eu/data/pan.svg', + currency: 'Panamanian balboa' + }, + { + name: 'Papua New Guinea', + capital: 'Port Moresby', + languages: ['English'], + population: 8083700, + flag: 'https://restcountries.eu/data/png.svg', + currency: 'Papua New Guinean kina' + }, + { + name: 'Paraguay', + capital: 'Asunción', + languages: ['Spanish', 'Guaraní'], + population: 6854536, + flag: 'https://restcountries.eu/data/pry.svg', + currency: 'Paraguayan guaraní' + }, + { + name: 'Peru', + capital: 'Lima', + languages: ['Spanish'], + population: 31488700, + flag: 'https://restcountries.eu/data/per.svg', + currency: 'Peruvian sol' + }, + { + name: 'Philippines', + capital: 'Manila', + languages: ['English'], + population: 103279800, + flag: 'https://restcountries.eu/data/phl.svg', + currency: 'Philippine peso' + }, + { + name: 'Pitcairn', + capital: 'Adamstown', + languages: ['English'], + population: 56, + flag: 'https://restcountries.eu/data/pcn.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Poland', + capital: 'Warsaw', + languages: ['Polish'], + population: 38437239, + flag: 'https://restcountries.eu/data/pol.svg', + currency: 'Polish złoty' + }, + { + name: 'Portugal', + capital: 'Lisbon', + languages: ['Portuguese'], + population: 10374822, + flag: 'https://restcountries.eu/data/prt.svg', + currency: 'Euro' + }, + { + name: 'Puerto Rico', + capital: 'San Juan', + languages: ['Spanish', 'English'], + population: 3474182, + flag: 'https://restcountries.eu/data/pri.svg', + currency: 'United States dollar' + }, + { + name: 'Qatar', + capital: 'Doha', + languages: ['Arabic'], + population: 2587564, + flag: 'https://restcountries.eu/data/qat.svg', + currency: 'Qatari riyal' + }, + { + name: 'Republic of Kosovo', + capital: 'Pristina', + languages: ['Albanian', 'Serbian'], + population: 1733842, + flag: 'https://restcountries.eu/data/kos.svg', + currency: 'Euro' + }, + { + name: 'Réunion', + capital: 'Saint-Denis', + languages: ['French'], + population: 840974, + flag: 'https://restcountries.eu/data/reu.svg', + currency: 'Euro' + }, + { + name: 'Romania', + capital: 'Bucharest', + languages: ['Romanian'], + population: 19861408, + flag: 'https://restcountries.eu/data/rou.svg', + currency: 'Romanian leu' + }, + { + name: 'Russian Federation', + capital: 'Moscow', + languages: ['Russian'], + population: 146599183, + flag: 'https://restcountries.eu/data/rus.svg', + currency: 'Russian ruble' + }, + { + name: 'Rwanda', + capital: 'Kigali', + languages: ['Kinyarwanda', 'English', 'French'], + population: 11553188, + flag: 'https://restcountries.eu/data/rwa.svg', + currency: 'Rwandan franc' + }, + { + name: 'Saint Barthélemy', + capital: 'Gustavia', + languages: ['French'], + population: 9417, + flag: 'https://restcountries.eu/data/blm.svg', + currency: 'Euro' + }, + { + name: 'Saint Helena, Ascension and Tristan da Cunha', + capital: 'Jamestown', + languages: ['English'], + population: 4255, + flag: 'https://restcountries.eu/data/shn.svg', + currency: 'Saint Helena pound' + }, + { + name: 'Saint Kitts and Nevis', + capital: 'Basseterre', + languages: ['English'], + population: 46204, + flag: 'https://restcountries.eu/data/kna.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Lucia', + capital: 'Castries', + languages: ['English'], + population: 186000, + flag: 'https://restcountries.eu/data/lca.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Martin (French part)', + capital: 'Marigot', + languages: ['English', 'French', 'Dutch'], + population: 36979, + flag: 'https://restcountries.eu/data/maf.svg', + currency: 'Euro' + }, + { + name: 'Saint Pierre and Miquelon', + capital: 'Saint-Pierre', + languages: ['French'], + population: 6069, + flag: 'https://restcountries.eu/data/spm.svg', + currency: 'Euro' + }, + { + name: 'Saint Vincent and the Grenadines', + capital: 'Kingstown', + languages: ['English'], + population: 109991, + flag: 'https://restcountries.eu/data/vct.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Samoa', + capital: 'Apia', + languages: ['Samoan', 'English'], + population: 194899, + flag: 'https://restcountries.eu/data/wsm.svg', + currency: 'Samoan tālā' + }, + { + name: 'San Marino', + capital: 'City of San Marino', + languages: ['Italian'], + population: 33005, + flag: 'https://restcountries.eu/data/smr.svg', + currency: 'Euro' + }, + { + name: 'Sao Tome and Principe', + capital: 'São Tomé', + languages: ['Portuguese'], + population: 187356, + flag: 'https://restcountries.eu/data/stp.svg', + currency: 'São Tomé and Príncipe dobra' + }, + { + name: 'Saudi Arabia', + capital: 'Riyadh', + languages: ['Arabic'], + population: 32248200, + flag: 'https://restcountries.eu/data/sau.svg', + currency: 'Saudi riyal' + }, + { + name: 'Senegal', + capital: 'Dakar', + languages: ['French'], + population: 14799859, + flag: 'https://restcountries.eu/data/sen.svg', + currency: 'West African CFA franc' + }, + { + name: 'Serbia', + capital: 'Belgrade', + languages: ['Serbian'], + population: 7076372, + flag: 'https://restcountries.eu/data/srb.svg', + currency: 'Serbian dinar' + }, + { + name: 'Seychelles', + capital: 'Victoria', + languages: ['French', 'English'], + population: 91400, + flag: 'https://restcountries.eu/data/syc.svg', + currency: 'Seychellois rupee' + }, + { + name: 'Sierra Leone', + capital: 'Freetown', + languages: ['English'], + population: 7075641, + flag: 'https://restcountries.eu/data/sle.svg', + currency: 'Sierra Leonean leone' + }, + { + name: 'Singapore', + capital: 'Singapore', + languages: ['English', 'Malay', 'Tamil', 'Chinese'], + population: 5535000, + flag: 'https://restcountries.eu/data/sgp.svg', + currency: 'Brunei dollar' + }, + { + name: 'Sint Maarten (Dutch part)', + capital: 'Philipsburg', + languages: ['Dutch', 'English'], + population: 38247, + flag: 'https://restcountries.eu/data/sxm.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Slovakia', + capital: 'Bratislava', + languages: ['Slovak'], + population: 5426252, + flag: 'https://restcountries.eu/data/svk.svg', + currency: 'Euro' + }, + { + name: 'Slovenia', + capital: 'Ljubljana', + languages: ['Slovene'], + population: 2064188, + flag: 'https://restcountries.eu/data/svn.svg', + currency: 'Euro' + }, + { + name: 'Solomon Islands', + capital: 'Honiara', + languages: ['English'], + population: 642000, + flag: 'https://restcountries.eu/data/slb.svg', + currency: 'Solomon Islands dollar' + }, + { + name: 'Somalia', + capital: 'Mogadishu', + languages: ['Somali', 'Arabic'], + population: 11079000, + flag: 'https://restcountries.eu/data/som.svg', + currency: 'Somali shilling' + }, + { + name: 'South Africa', + capital: 'Pretoria', + languages: [ + 'Afrikaans', + 'English', + 'Southern Ndebele', + 'Southern Sotho', + 'Swati', + 'Tswana', + 'Tsonga', + 'Venda', + 'Xhosa', + 'Zulu' + ], + population: 55653654, + flag: 'https://restcountries.eu/data/zaf.svg', + currency: 'South African rand' + }, + { + name: 'South Georgia and the South Sandwich Islands', + capital: 'King Edward Point', + languages: ['English'], + population: 30, + flag: 'https://restcountries.eu/data/sgs.svg', + currency: 'British pound' + }, + { + name: 'Korea (Republic of)', + capital: 'Seoul', + languages: ['Korean'], + population: 50801405, + flag: 'https://restcountries.eu/data/kor.svg', + currency: 'South Korean won' + }, + { + name: 'South Sudan', + capital: 'Juba', + languages: ['English'], + population: 12131000, + flag: 'https://restcountries.eu/data/ssd.svg', + currency: 'South Sudanese pound' + }, + { + name: 'Spain', + capital: 'Madrid', + languages: ['Spanish'], + population: 46438422, + flag: 'https://restcountries.eu/data/esp.svg', + currency: 'Euro' + }, + { + name: 'Sri Lanka', + capital: 'Colombo', + languages: ['Sinhalese', 'Tamil'], + population: 20966000, + flag: 'https://restcountries.eu/data/lka.svg', + currency: 'Sri Lankan rupee' + }, + { + name: 'Sudan', + capital: 'Khartoum', + languages: ['Arabic', 'English'], + population: 39598700, + flag: 'https://restcountries.eu/data/sdn.svg', + currency: 'Sudanese pound' + }, + { + name: 'Suriname', + capital: 'Paramaribo', + languages: ['Dutch'], + population: 541638, + flag: 'https://restcountries.eu/data/sur.svg', + currency: 'Surinamese dollar' + }, + { + name: 'Svalbard and Jan Mayen', + capital: 'Longyearbyen', + languages: ['Norwegian'], + population: 2562, + flag: 'https://restcountries.eu/data/sjm.svg', + currency: 'Norwegian krone' + }, + { + name: 'Swaziland', + capital: 'Lobamba', + languages: ['English', 'Swati'], + population: 1132657, + flag: 'https://restcountries.eu/data/swz.svg', + currency: 'Swazi lilangeni' + }, + { + name: 'Sweden', + capital: 'Stockholm', + languages: ['Swedish'], + population: 9894888, + flag: 'https://restcountries.eu/data/swe.svg', + currency: 'Swedish krona' + }, + { + name: 'Switzerland', + capital: 'Bern', + languages: ['German', 'French', 'Italian'], + population: 8341600, + flag: 'https://restcountries.eu/data/che.svg', + currency: 'Swiss franc' + }, + { + name: 'Syrian Arab Republic', + capital: 'Damascus', + languages: ['Arabic'], + population: 18564000, + flag: 'https://restcountries.eu/data/syr.svg', + currency: 'Syrian pound' + }, + { + name: 'Taiwan', + capital: 'Taipei', + languages: ['Chinese'], + population: 23503349, + flag: 'https://restcountries.eu/data/twn.svg', + currency: 'New Taiwan dollar' + }, + { + name: 'Tajikistan', + capital: 'Dushanbe', + languages: ['Tajik', 'Russian'], + population: 8593600, + flag: 'https://restcountries.eu/data/tjk.svg', + currency: 'Tajikistani somoni' + }, + { + name: 'Tanzania, United Republic of', + capital: 'Dodoma', + languages: ['Swahili', 'English'], + population: 55155000, + flag: 'https://restcountries.eu/data/tza.svg', + currency: 'Tanzanian shilling' + }, + { + name: 'Thailand', + capital: 'Bangkok', + languages: ['Thai'], + population: 65327652, + flag: 'https://restcountries.eu/data/tha.svg', + currency: 'Thai baht' + }, + { + name: 'Timor-Leste', + capital: 'Dili', + languages: ['Portuguese'], + population: 1167242, + flag: 'https://restcountries.eu/data/tls.svg', + currency: 'United States dollar' + }, + { + name: 'Togo', + capital: 'Lomé', + languages: ['French'], + population: 7143000, + flag: 'https://restcountries.eu/data/tgo.svg', + currency: 'West African CFA franc' + }, + { + name: 'Tokelau', + capital: 'Fakaofo', + languages: ['English'], + population: 1411, + flag: 'https://restcountries.eu/data/tkl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Tonga', + capital: "Nuku'alofa", + languages: ['English', 'Tonga (Tonga Islands)'], + population: 103252, + flag: 'https://restcountries.eu/data/ton.svg', + currency: 'Tongan paʻanga' + }, + { + name: 'Trinidad and Tobago', + capital: 'Port of Spain', + languages: ['English'], + population: 1349667, + flag: 'https://restcountries.eu/data/tto.svg', + currency: 'Trinidad and Tobago dollar' + }, + { + name: 'Tunisia', + capital: 'Tunis', + languages: ['Arabic'], + population: 11154400, + flag: 'https://restcountries.eu/data/tun.svg', + currency: 'Tunisian dinar' + }, + { + name: 'Turkey', + capital: 'Ankara', + languages: ['Turkish'], + population: 78741053, + flag: 'https://restcountries.eu/data/tur.svg', + currency: 'Turkish lira' + }, + { + name: 'Turkmenistan', + capital: 'Ashgabat', + languages: ['Turkmen', 'Russian'], + population: 4751120, + flag: 'https://restcountries.eu/data/tkm.svg', + currency: 'Turkmenistan manat' + }, + { + name: 'Turks and Caicos Islands', + capital: 'Cockburn Town', + languages: ['English'], + population: 31458, + flag: 'https://restcountries.eu/data/tca.svg', + currency: 'United States dollar' + }, + { + name: 'Tuvalu', + capital: 'Funafuti', + languages: ['English'], + population: 10640, + flag: 'https://restcountries.eu/data/tuv.svg', + currency: 'Australian dollar' + }, + { + name: 'Uganda', + capital: 'Kampala', + languages: ['English', 'Swahili'], + population: 33860700, + flag: 'https://restcountries.eu/data/uga.svg', + currency: 'Ugandan shilling' + }, + { + name: 'Ukraine', + capital: 'Kiev', + languages: ['Ukrainian'], + population: 42692393, + flag: 'https://restcountries.eu/data/ukr.svg', + currency: 'Ukrainian hryvnia' + }, + { + name: 'United Arab Emirates', + capital: 'Abu Dhabi', + languages: ['Arabic'], + population: 9856000, + flag: 'https://restcountries.eu/data/are.svg', + currency: 'United Arab Emirates dirham' + }, + { + name: 'United Kingdom of Great Britain and Northern Ireland', + capital: 'London', + languages: ['English'], + population: 65110000, + flag: 'https://restcountries.eu/data/gbr.svg', + currency: 'British pound' + }, + { + name: 'United States of America', + capital: 'Washington, D.C.', + languages: ['English'], + population: 323947000, + flag: 'https://restcountries.eu/data/usa.svg', + currency: 'United States dollar' + }, + { + name: 'Uruguay', + capital: 'Montevideo', + languages: ['Spanish'], + population: 3480222, + flag: 'https://restcountries.eu/data/ury.svg', + currency: 'Uruguayan peso' + }, + { + name: 'Uzbekistan', + capital: 'Tashkent', + languages: ['Uzbek', 'Russian'], + population: 31576400, + flag: 'https://restcountries.eu/data/uzb.svg', + currency: "Uzbekistani so'm" + }, + { + name: 'Vanuatu', + capital: 'Port Vila', + languages: ['Bislama', 'English', 'French'], + population: 277500, + flag: 'https://restcountries.eu/data/vut.svg', + currency: 'Vanuatu vatu' + }, + { + name: 'Venezuela (Bolivarian Republic of)', + capital: 'Caracas', + languages: ['Spanish'], + population: 31028700, + flag: 'https://restcountries.eu/data/ven.svg', + currency: 'Venezuelan bolívar' + }, + { + name: 'Viet Nam', + capital: 'Hanoi', + languages: ['Vietnamese'], + population: 92700000, + flag: 'https://restcountries.eu/data/vnm.svg', + currency: 'Vietnamese đồng' + }, + { + name: 'Wallis and Futuna', + capital: 'Mata-Utu', + languages: ['French'], + population: 11750, + flag: 'https://restcountries.eu/data/wlf.svg', + currency: 'CFP franc' + }, + { + name: 'Western Sahara', + capital: 'El Aaiún', + languages: ['Spanish'], + population: 510713, + flag: 'https://restcountries.eu/data/esh.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Yemen', + capital: "Sana'a", + languages: ['Arabic'], + population: 27478000, + flag: 'https://restcountries.eu/data/yem.svg', + currency: 'Yemeni rial' + }, + { + name: 'Zambia', + capital: 'Lusaka', + languages: ['English'], + population: 15933883, + flag: 'https://restcountries.eu/data/zmb.svg', + currency: 'Zambian kwacha' + }, + { + name: 'Zimbabwe', + capital: 'Harare', + languages: ['English', 'Shona', 'Northern Ndebele'], + population: 14240168, + flag: 'https://restcountries.eu/data/zwe.svg', + currency: 'Botswana pula' + } +] diff --git a/12_Day_Regular_expressions/12_day_starter/index.html b/12_Day_Regular_expressions/12_day_starter/index.html new file mode 100644 index 0000000..6efcab4 --- /dev/null +++ b/12_Day_Regular_expressions/12_day_starter/index.html @@ -0,0 +1,17 @@ + + + + + 30DaysOfJavaScript:11 Day + + + +

30DaysOfJavaScript:11 Day

+

Destructuring and Spread

+ + + + + + + \ No newline at end of file diff --git a/12_Day_Regular_expressions/12_day_starter/scripts/main.js b/12_Day_Regular_expressions/12_day_starter/scripts/main.js new file mode 100644 index 0000000..c6045c8 --- /dev/null +++ b/12_Day_Regular_expressions/12_day_starter/scripts/main.js @@ -0,0 +1,2 @@ +console.log(countries) +alert('Open the console and check if the countries has been loaded') \ No newline at end of file diff --git a/13_Day_Console_object_methods/13_day_console_object_methods.md b/13_Day_Console_object_methods/13_day_console_object_methods.md new file mode 100644 index 0000000..f17cf29 --- /dev/null +++ b/13_Day_Console_object_methods/13_day_console_object_methods.md @@ -0,0 +1,358 @@ +
+

30 Days Of JavaScript: Console Object Methods

+ + + + + Twitter Follow + + +Author: +Asabeneh Yetayeh
+ January, 2020 +
+ +
+ +[<< Day 12](../12_Day_Regular_expressions/12_day_regular_expressions.md) | [Day 14>>](../14_Day_Error_handling/14_day_error_handling.md) + +![Thirty Days Of JavaScript](../images/banners/day_1_13.png) + +- [Day 13](#day-13) + - [Console Object Methods](#console-object-methods) + - [console.log()](#consolelog) + - [console.warn()](#consolewarn) + - [console.error()](#consoleerror) + - [console.table()](#consoletable) + - [console.time()](#consoletime) + - [console.info()](#consoleinfo) + - [console.assert()](#consoleassert) + - [console.group()](#consolegroup) + - [console.count()](#consolecount) + - [console.clear()](#consoleclear) + - [Exercises](#exercises) + - [Exercises:Level 1](#exerciseslevel-1) + - [Exercises:Level 2](#exerciseslevel-2) + - [Exercises:Level 3](#exerciseslevel-3) + +# Day 13 + +## Console Object Methods + +In this section, we will cover about console and console object methods. Absolute beginners usually do not know which to use: console.log(), document.write() or document.getElementById. + +We use console object methods to show output on the browser console and we use document.write to show output on the browser document(view port). Both methods used only for testing and debugging purposes. The console method is the most popular testing and debugging tool on the browser. We use document.getElementById() when we like to interact with DOM try using JavaScript. We will cover DOM in another section. + +In addition to the famous, console.log() method, the console provides other more methods methods. + +### console.log() + +We use console.log() to show output on the browser console. We can substitute values and also we can style the logging out put using %c. + +- Showing output on browser console + +```js +console.log('30 Days of JavaScript') +``` + +```sh +30 Days of JavaScript +``` + +- Substitution + +```js +console.log('%d %s of JavaScript', 30, 'Days') +``` + +```sh +30 Days of JavaScript +``` + +- CSS + +We can style logging message using css. Copy the following code and paste it on browser console to see the result. + +```js +console.log('%c30 Days Of JavaScript', 'color:green') // log output is green +console.log( + '%c30 Days%c %cOf%c %cJavaScript%c', + 'color:green', + '', + 'color:red', + '', + 'color:yellow' +) // log output green red and yellow text +``` + +### console.warn() + +We use console.warn() to give warning on browser. For instance to inform or warn deprecation of version of a package or bad practices. Copy the following code and paste it on browser console to see warning messages. + +```js +console.warn('This is a warning') +console.warn( + 'You are using React. Do not touch the DOM. Virtual DOM will take care of handling the DOM!' +) +console.warn('Warning is different from error') +``` + +### console.error() + +The console.error() methods shows an error messages. + +```js +console.error('This is an error message') +console.error('We all make mistakes') +``` + +### console.table() + +The console.table() method display data as a table on the console. Displays tabular data as a table. The console.table() takes one required argument data, which must be an array or an object, and one additional optional parameter columns. + +Let us first start with a simple array. The code below displays a table with two columns. An index column to display the index and value column to display the names + +```js +const names = ['Asabeneh', 'Brook', 'David', 'John'] +console.table(names) +``` + +Let us also check the result of an object. This creates table with two columns:an index column containing the keys and a value column contain the values of the object. + +```js +const user = { + name: 'Asabeneh', + title: 'Programmer', + country: 'Finland', + city: 'Helsinki', + age: 250 +} +console.table(user) +``` + +Check the rest of the examples by copying and paste on the browser console. + +```js +const countries = [ + ['Finland', 'Helsinki'], + ['Sweden', 'Stockholm'], + ['Norway', 'Oslo'] +] +console.table(countries) +``` + +```js +const users = [ + { + name: 'Asabeneh', + title: 'Programmer', + country: 'Finland', + city: 'Helsinki', + age: 250 + }, + { + name: 'Eyob', + title: 'Teacher', + country: 'Sweden', + city: 'London', + age: 25 + }, + { + name: 'Asab', + title: 'Instructor', + country: 'Norway', + city: 'Oslo', + age: 22 + }, + { + name: 'Matias', + title: 'Developer', + country: 'Denmark', + city: 'Copenhagen', + age: 28 + } +] +console.table(users) +``` + +### console.time() + +Starts a timer you can use to track how long an operation takes. You give each timer a unique name, and may have up to 10,000 timers running on a given page. When you call console.timeEnd() with the same name, the browser will output the time, in milliseconds, that elapsed since the timer was started. + +```js +const countries = [ + ['Finland', 'Helsinki'], + ['Sweden', 'Stockholm'], + ['Norway', 'Oslo'] +] + +console.time('Regular for loop') +for (let i = 0; i < countries.length; i++) { + console.log(countries[i][0], countries[i][1]) +} +console.timeEnd('Regular for loop') + +console.time('for of loop') +for (const [name, city] of countries) { + console.log(name, city) +} +console.timeEnd('for of loop') + +console.time('forEach loop') +countries.forEach(([name, city]) => { + console.log(name, city) +}) +console.timeEnd('forEach loop') +``` + +```sh +Finland Helsinki +Sweden Stockholm +Norway Oslo +Regular for loop: 0.34716796875ms +Finland Helsinki +Sweden Stockholm +Norway Oslo +for of loop: 0.26806640625ms +Finland Helsinki +Sweden Stockholm +Norway Oslo +forEach loop: 0.358154296875ms +``` + +According the above output the regular for loop is slower than for of or forEach loop. + +### console.info() + +It display information message on browser console. + +```js +console.info('30 Days Of JavaScript challenge is trending on Github') +console.info('30 Days Of fullStack challenge might be released') +console.info('30 Days Of HTML and CSS challenge might be released') +``` + +### console.assert() + +The console.assert() methods writes an error message to the console if the assertion is false. If the assertion is true, nothing happens. The first parameter is an assertion expression. If this expression is false, an Assertion failed error message will be displayed. + +```js +console.assert(4 > 3, '4 is greater than 3') // no result +console.assert(3 > 4, '3 is not greater than 4') // Assertion failed: 3 is not greater than 4 + +for (let i = 0; i <= 10; i += 1) { + let errorMessage = `${i} is not even` + console.log('the # is ' + i) + console.assert(i % 2 === 0, { number: i, errorMessage: errorMessage }) +} +``` + +### console.group() + +The console.group() can help to group different log groups. Copy the following code and paste it on browser console to the groups. + +```js +const names = ['Asabeneh', 'Brook', 'David', 'John'] +const countries = [ + ['Finland', 'Helsinki'], + ['Sweden', 'Stockholm'], + ['Norway', 'Oslo'] +] +const user = { + name: 'Asabeneh', + title: 'Programmer', + country: 'Finland', + city: 'Helsinki', + age: 250 +} +const users = [ + { + name: 'Asabeneh', + title: 'Programmer', + country: 'Finland', + city: 'Helsinki', + age: 250 + }, + { + name: 'Eyob', + title: 'Teacher', + country: 'Sweden', + city: 'London', + age: 25 + }, + { + name: 'Asab', + title: 'Instructor', + country: 'Norway', + city: 'Oslo', + age: 22 + }, + { + name: 'Matias', + title: 'Developer', + country: 'Denmark', + city: 'Copenhagen', + age: 28 + } +] + +console.group('Names') +console.log(names) +console.groupEnd() + +console.group('Countries') +console.log(countries) +console.groupEnd() + +console.group('Users') +console.log(user) +console.log(users) +console.groupEnd() +``` + +### console.count() + +It prints the number of time this console.count() is called. It takes a string label parameter. It is very helpful to count the number of times a function is called. In the following example, the console.count() method will run three times + +```js +const func = () => { + console.count('Function has been called') +} +func() +func() +func() +``` + +```sh +Function has been called: 1 +Function has been called: 2 +Function has been called: 3 +``` + +### console.clear() + +The console.clear() cleans the browser console. + +🌕 Keep up the good work. Keep pushing, the sky is the limit! You have just completed day 13 challenges and you are 13 steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle. + +## Exercises + +### Exercises:Level 1 + +1. Display the countries array as a table +2. Display the countries object as a table +3. Use console.group() to group logs + +### Exercises:Level 2 + +1. 10 > 2 \* 10 use console.assert() +2. Write a warning message using console.warn() +3. Write an error message using console.error() + +### Exercises:Level 3 + +1. Check the speed difference among the following loops: while, for, for of, forEach + +🎉 CONGRATULATIONS ! 🎉 + +[<< Day 12](../12_Day_Regular_expressions/12_day_regular_expressions.md) | [Day 14>>](../14_Day_Error_handling/14_day_error_handling.md) diff --git a/13_Day_Console_object_methods/13_day_starter/data/countries_data.js b/13_Day_Console_object_methods/13_day_starter/data/countries_data.js new file mode 100644 index 0000000..92acddd --- /dev/null +++ b/13_Day_Console_object_methods/13_day_starter/data/countries_data.js @@ -0,0 +1,2013 @@ +const countries = [ + { + name: 'Afghanistan', + capital: 'Kabul', + languages: ['Pashto', 'Uzbek', 'Turkmen'], + population: 27657145, + flag: 'https://restcountries.eu/data/afg.svg', + currency: 'Afghan afghani' + }, + { + name: 'Åland Islands', + capital: 'Mariehamn', + languages: ['Swedish'], + population: 28875, + flag: 'https://restcountries.eu/data/ala.svg', + currency: 'Euro' + }, + { + name: 'Albania', + capital: 'Tirana', + languages: ['Albanian'], + population: 2886026, + flag: 'https://restcountries.eu/data/alb.svg', + currency: 'Albanian lek' + }, + { + name: 'Algeria', + capital: 'Algiers', + languages: ['Arabic'], + population: 40400000, + flag: 'https://restcountries.eu/data/dza.svg', + currency: 'Algerian dinar' + }, + { + name: 'American Samoa', + capital: 'Pago Pago', + languages: ['English', 'Samoan'], + population: 57100, + flag: 'https://restcountries.eu/data/asm.svg', + currency: 'United State Dollar' + }, + { + name: 'Andorra', + capital: 'Andorra la Vella', + languages: ['Catalan'], + population: 78014, + flag: 'https://restcountries.eu/data/and.svg', + currency: 'Euro' + }, + { + name: 'Angola', + capital: 'Luanda', + languages: ['Portuguese'], + population: 25868000, + flag: 'https://restcountries.eu/data/ago.svg', + currency: 'Angolan kwanza' + }, + { + name: 'Anguilla', + capital: 'The Valley', + languages: ['English'], + population: 13452, + flag: 'https://restcountries.eu/data/aia.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Antarctica', + capital: '', + languages: ['English', 'Russian'], + population: 1000, + flag: 'https://restcountries.eu/data/ata.svg', + currency: 'Australian dollar' + }, + { + name: 'Antigua and Barbuda', + capital: "Saint John's", + languages: ['English'], + population: 86295, + flag: 'https://restcountries.eu/data/atg.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Argentina', + capital: 'Buenos Aires', + languages: ['Spanish', 'Guaraní'], + population: 43590400, + flag: 'https://restcountries.eu/data/arg.svg', + currency: 'Argentine peso' + }, + { + name: 'Armenia', + capital: 'Yerevan', + languages: ['Armenian', 'Russian'], + population: 2994400, + flag: 'https://restcountries.eu/data/arm.svg', + currency: 'Armenian dram' + }, + { + name: 'Aruba', + capital: 'Oranjestad', + languages: ['Dutch', '(Eastern) Punjabi'], + population: 107394, + flag: 'https://restcountries.eu/data/abw.svg', + currency: 'Aruban florin' + }, + { + name: 'Australia', + capital: 'Canberra', + languages: ['English'], + population: 24117360, + flag: 'https://restcountries.eu/data/aus.svg', + currency: 'Australian dollar' + }, + { + name: 'Austria', + capital: 'Vienna', + languages: ['German'], + population: 8725931, + flag: 'https://restcountries.eu/data/aut.svg', + currency: 'Euro' + }, + { + name: 'Azerbaijan', + capital: 'Baku', + languages: ['Azerbaijani'], + population: 9730500, + flag: 'https://restcountries.eu/data/aze.svg', + currency: 'Azerbaijani manat' + }, + { + name: 'Bahamas', + capital: 'Nassau', + languages: ['English'], + population: 378040, + flag: 'https://restcountries.eu/data/bhs.svg', + currency: 'Bahamian dollar' + }, + { + name: 'Bahrain', + capital: 'Manama', + languages: ['Arabic'], + population: 1404900, + flag: 'https://restcountries.eu/data/bhr.svg', + currency: 'Bahraini dinar' + }, + { + name: 'Bangladesh', + capital: 'Dhaka', + languages: ['Bengali'], + population: 161006790, + flag: 'https://restcountries.eu/data/bgd.svg', + currency: 'Bangladeshi taka' + }, + { + name: 'Barbados', + capital: 'Bridgetown', + languages: ['English'], + population: 285000, + flag: 'https://restcountries.eu/data/brb.svg', + currency: 'Barbadian dollar' + }, + { + name: 'Belarus', + capital: 'Minsk', + languages: ['Belarusian', 'Russian'], + population: 9498700, + flag: 'https://restcountries.eu/data/blr.svg', + currency: 'New Belarusian ruble' + }, + { + name: 'Belgium', + capital: 'Brussels', + languages: ['Dutch', 'French', 'German'], + population: 11319511, + flag: 'https://restcountries.eu/data/bel.svg', + currency: 'Euro' + }, + { + name: 'Belize', + capital: 'Belmopan', + languages: ['English', 'Spanish'], + population: 370300, + flag: 'https://restcountries.eu/data/blz.svg', + currency: 'Belize dollar' + }, + { + name: 'Benin', + capital: 'Porto-Novo', + languages: ['French'], + population: 10653654, + flag: 'https://restcountries.eu/data/ben.svg', + currency: 'West African CFA franc' + }, + { + name: 'Bermuda', + capital: 'Hamilton', + languages: ['English'], + population: 61954, + flag: 'https://restcountries.eu/data/bmu.svg', + currency: 'Bermudian dollar' + }, + { + name: 'Bhutan', + capital: 'Thimphu', + languages: ['Dzongkha'], + population: 775620, + flag: 'https://restcountries.eu/data/btn.svg', + currency: 'Bhutanese ngultrum' + }, + { + name: 'Bolivia (Plurinational State of)', + capital: 'Sucre', + languages: ['Spanish', 'Aymara', 'Quechua'], + population: 10985059, + flag: 'https://restcountries.eu/data/bol.svg', + currency: 'Bolivian boliviano' + }, + { + name: 'Bonaire, Sint Eustatius and Saba', + capital: 'Kralendijk', + languages: ['Dutch'], + population: 17408, + flag: 'https://restcountries.eu/data/bes.svg', + currency: 'United States dollar' + }, + { + name: 'Bosnia and Herzegovina', + capital: 'Sarajevo', + languages: ['Bosnian', 'Croatian', 'Serbian'], + population: 3531159, + flag: 'https://restcountries.eu/data/bih.svg', + currency: 'Bosnia and Herzegovina convertible mark' + }, + { + name: 'Botswana', + capital: 'Gaborone', + languages: ['English', 'Tswana'], + population: 2141206, + flag: 'https://restcountries.eu/data/bwa.svg', + currency: 'Botswana pula' + }, + { + name: 'Bouvet Island', + capital: '', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 0, + flag: 'https://restcountries.eu/data/bvt.svg', + currency: 'Norwegian krone' + }, + { + name: 'Brazil', + capital: 'Brasília', + languages: ['Portuguese'], + population: 206135893, + flag: 'https://restcountries.eu/data/bra.svg', + currency: 'Brazilian real' + }, + { + name: 'British Indian Ocean Territory', + capital: 'Diego Garcia', + languages: ['English'], + population: 3000, + flag: 'https://restcountries.eu/data/iot.svg', + currency: 'United States dollar' + }, + { + name: 'United States Minor Outlying Islands', + capital: '', + languages: ['English'], + population: 300, + flag: 'https://restcountries.eu/data/umi.svg', + currency: 'United States Dollar' + }, + { + name: 'Virgin Islands (British)', + capital: 'Road Town', + languages: ['English'], + population: 28514, + flag: 'https://restcountries.eu/data/vgb.svg', + currency: '[D]' + }, + { + name: 'Virgin Islands (U.S.)', + capital: 'Charlotte Amalie', + languages: ['English'], + population: 114743, + flag: 'https://restcountries.eu/data/vir.svg', + currency: 'United States dollar' + }, + { + name: 'Brunei Darussalam', + capital: 'Bandar Seri Begawan', + languages: ['Malay'], + population: 411900, + flag: 'https://restcountries.eu/data/brn.svg', + currency: 'Brunei dollar' + }, + { + name: 'Bulgaria', + capital: 'Sofia', + languages: ['Bulgarian'], + population: 7153784, + flag: 'https://restcountries.eu/data/bgr.svg', + currency: 'Bulgarian lev' + }, + { + name: 'Burkina Faso', + capital: 'Ouagadougou', + languages: ['French', 'Fula'], + population: 19034397, + flag: 'https://restcountries.eu/data/bfa.svg', + currency: 'West African CFA franc' + }, + { + name: 'Burundi', + capital: 'Bujumbura', + languages: ['French', 'Kirundi'], + population: 10114505, + flag: 'https://restcountries.eu/data/bdi.svg', + currency: 'Burundian franc' + }, + { + name: 'Cambodia', + capital: 'Phnom Penh', + languages: ['Khmer'], + population: 15626444, + flag: 'https://restcountries.eu/data/khm.svg', + currency: 'Cambodian riel' + }, + { + name: 'Cameroon', + capital: 'Yaoundé', + languages: ['English', 'French'], + population: 22709892, + flag: 'https://restcountries.eu/data/cmr.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Canada', + capital: 'Ottawa', + languages: ['English', 'French'], + population: 36155487, + flag: 'https://restcountries.eu/data/can.svg', + currency: 'Canadian dollar' + }, + { + name: 'Cabo Verde', + capital: 'Praia', + languages: ['Portuguese'], + population: 531239, + flag: 'https://restcountries.eu/data/cpv.svg', + currency: 'Cape Verdean escudo' + }, + { + name: 'Cayman Islands', + capital: 'George Town', + languages: ['English'], + population: 58238, + flag: 'https://restcountries.eu/data/cym.svg', + currency: 'Cayman Islands dollar' + }, + { + name: 'Central African Republic', + capital: 'Bangui', + languages: ['French', 'Sango'], + population: 4998000, + flag: 'https://restcountries.eu/data/caf.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chad', + capital: "N'Djamena", + languages: ['French', 'Arabic'], + population: 14497000, + flag: 'https://restcountries.eu/data/tcd.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chile', + capital: 'Santiago', + languages: ['Spanish'], + population: 18191900, + flag: 'https://restcountries.eu/data/chl.svg', + currency: 'Chilean peso' + }, + { + name: 'China', + capital: 'Beijing', + languages: ['Chinese'], + population: 1377422166, + flag: 'https://restcountries.eu/data/chn.svg', + currency: 'Chinese yuan' + }, + { + name: 'Christmas Island', + capital: 'Flying Fish Cove', + languages: ['English'], + population: 2072, + flag: 'https://restcountries.eu/data/cxr.svg', + currency: 'Australian dollar' + }, + { + name: 'Cocos (Keeling) Islands', + capital: 'West Island', + languages: ['English'], + population: 550, + flag: 'https://restcountries.eu/data/cck.svg', + currency: 'Australian dollar' + }, + { + name: 'Colombia', + capital: 'Bogotá', + languages: ['Spanish'], + population: 48759958, + flag: 'https://restcountries.eu/data/col.svg', + currency: 'Colombian peso' + }, + { + name: 'Comoros', + capital: 'Moroni', + languages: ['Arabic', 'French'], + population: 806153, + flag: 'https://restcountries.eu/data/com.svg', + currency: 'Comorian franc' + }, + { + name: 'Congo', + capital: 'Brazzaville', + languages: ['French', 'Lingala'], + population: 4741000, + flag: 'https://restcountries.eu/data/cog.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Congo (Democratic Republic of the)', + capital: 'Kinshasa', + languages: ['French', 'Lingala', 'Kongo', 'Swahili', 'Luba-Katanga'], + population: 85026000, + flag: 'https://restcountries.eu/data/cod.svg', + currency: 'Congolese franc' + }, + { + name: 'Cook Islands', + capital: 'Avarua', + languages: ['English'], + population: 18100, + flag: 'https://restcountries.eu/data/cok.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Costa Rica', + capital: 'San José', + languages: ['Spanish'], + population: 4890379, + flag: 'https://restcountries.eu/data/cri.svg', + currency: 'Costa Rican colón' + }, + { + name: 'Croatia', + capital: 'Zagreb', + languages: ['Croatian'], + population: 4190669, + flag: 'https://restcountries.eu/data/hrv.svg', + currency: 'Croatian kuna' + }, + { + name: 'Cuba', + capital: 'Havana', + languages: ['Spanish'], + population: 11239004, + flag: 'https://restcountries.eu/data/cub.svg', + currency: 'Cuban convertible peso' + }, + { + name: 'Curaçao', + capital: 'Willemstad', + languages: ['Dutch', '(Eastern) Punjabi', 'English'], + population: 154843, + flag: 'https://restcountries.eu/data/cuw.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Cyprus', + capital: 'Nicosia', + languages: ['Greek (modern)', 'Turkish', 'Armenian'], + population: 847000, + flag: 'https://restcountries.eu/data/cyp.svg', + currency: 'Euro' + }, + { + name: 'Czech Republic', + capital: 'Prague', + languages: ['Czech', 'Slovak'], + population: 10558524, + flag: 'https://restcountries.eu/data/cze.svg', + currency: 'Czech koruna' + }, + { + name: 'Denmark', + capital: 'Copenhagen', + languages: ['Danish'], + population: 5717014, + flag: 'https://restcountries.eu/data/dnk.svg', + currency: 'Danish krone' + }, + { + name: 'Djibouti', + capital: 'Djibouti', + languages: ['French', 'Arabic'], + population: 900000, + flag: 'https://restcountries.eu/data/dji.svg', + currency: 'Djiboutian franc' + }, + { + name: 'Dominica', + capital: 'Roseau', + languages: ['English'], + population: 71293, + flag: 'https://restcountries.eu/data/dma.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Dominican Republic', + capital: 'Santo Domingo', + languages: ['Spanish'], + population: 10075045, + flag: 'https://restcountries.eu/data/dom.svg', + currency: 'Dominican peso' + }, + { + name: 'Ecuador', + capital: 'Quito', + languages: ['Spanish'], + population: 16545799, + flag: 'https://restcountries.eu/data/ecu.svg', + currency: 'United States dollar' + }, + { + name: 'Egypt', + capital: 'Cairo', + languages: ['Arabic'], + population: 91290000, + flag: 'https://restcountries.eu/data/egy.svg', + currency: 'Egyptian pound' + }, + { + name: 'El Salvador', + capital: 'San Salvador', + languages: ['Spanish'], + population: 6520675, + flag: 'https://restcountries.eu/data/slv.svg', + currency: 'United States dollar' + }, + { + name: 'Equatorial Guinea', + capital: 'Malabo', + languages: ['Spanish', 'French'], + population: 1222442, + flag: 'https://restcountries.eu/data/gnq.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Eritrea', + capital: 'Asmara', + languages: ['Tigrinya', 'Arabic', 'English'], + population: 5352000, + flag: 'https://restcountries.eu/data/eri.svg', + currency: 'Eritrean nakfa' + }, + { + name: 'Estonia', + capital: 'Tallinn', + languages: ['Estonian'], + population: 1315944, + flag: 'https://restcountries.eu/data/est.svg', + currency: 'Euro' + }, + { + name: 'Ethiopia', + capital: 'Addis Ababa', + languages: ['Amharic'], + population: 92206005, + flag: 'https://restcountries.eu/data/eth.svg', + currency: 'Ethiopian birr' + }, + { + name: 'Falkland Islands (Malvinas)', + capital: 'Stanley', + languages: ['English'], + population: 2563, + flag: 'https://restcountries.eu/data/flk.svg', + currency: 'Falkland Islands pound' + }, + { + name: 'Faroe Islands', + capital: 'Tórshavn', + languages: ['Faroese'], + population: 49376, + flag: 'https://restcountries.eu/data/fro.svg', + currency: 'Danish krone' + }, + { + name: 'Fiji', + capital: 'Suva', + languages: ['English', 'Fijian', 'Hindi', 'Urdu'], + population: 867000, + flag: 'https://restcountries.eu/data/fji.svg', + currency: 'Fijian dollar' + }, + { + name: 'Finland', + capital: 'Helsinki', + languages: ['Finnish', 'Swedish'], + population: 5491817, + flag: 'https://restcountries.eu/data/fin.svg', + currency: 'Euro' + }, + { + name: 'France', + capital: 'Paris', + languages: ['French'], + population: 66710000, + flag: 'https://restcountries.eu/data/fra.svg', + currency: 'Euro' + }, + { + name: 'French Guiana', + capital: 'Cayenne', + languages: ['French'], + population: 254541, + flag: 'https://restcountries.eu/data/guf.svg', + currency: 'Euro' + }, + { + name: 'French Polynesia', + capital: 'Papeetē', + languages: ['French'], + population: 271800, + flag: 'https://restcountries.eu/data/pyf.svg', + currency: 'CFP franc' + }, + { + name: 'French Southern Territories', + capital: 'Port-aux-Français', + languages: ['French'], + population: 140, + flag: 'https://restcountries.eu/data/atf.svg', + currency: 'Euro' + }, + { + name: 'Gabon', + capital: 'Libreville', + languages: ['French'], + population: 1802278, + flag: 'https://restcountries.eu/data/gab.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Gambia', + capital: 'Banjul', + languages: ['English'], + population: 1882450, + flag: 'https://restcountries.eu/data/gmb.svg', + currency: 'Gambian dalasi' + }, + { + name: 'Georgia', + capital: 'Tbilisi', + languages: ['Georgian'], + population: 3720400, + flag: 'https://restcountries.eu/data/geo.svg', + currency: 'Georgian Lari' + }, + { + name: 'Germany', + capital: 'Berlin', + languages: ['German'], + population: 81770900, + flag: 'https://restcountries.eu/data/deu.svg', + currency: 'Euro' + }, + { + name: 'Ghana', + capital: 'Accra', + languages: ['English'], + population: 27670174, + flag: 'https://restcountries.eu/data/gha.svg', + currency: 'Ghanaian cedi' + }, + { + name: 'Gibraltar', + capital: 'Gibraltar', + languages: ['English'], + population: 33140, + flag: 'https://restcountries.eu/data/gib.svg', + currency: 'Gibraltar pound' + }, + { + name: 'Greece', + capital: 'Athens', + languages: ['Greek (modern)'], + population: 10858018, + flag: 'https://restcountries.eu/data/grc.svg', + currency: 'Euro' + }, + { + name: 'Greenland', + capital: 'Nuuk', + languages: ['Kalaallisut'], + population: 55847, + flag: 'https://restcountries.eu/data/grl.svg', + currency: 'Danish krone' + }, + { + name: 'Grenada', + capital: "St. George's", + languages: ['English'], + population: 103328, + flag: 'https://restcountries.eu/data/grd.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Guadeloupe', + capital: 'Basse-Terre', + languages: ['French'], + population: 400132, + flag: 'https://restcountries.eu/data/glp.svg', + currency: 'Euro' + }, + { + name: 'Guam', + capital: 'Hagåtña', + languages: ['English', 'Chamorro', 'Spanish'], + population: 184200, + flag: 'https://restcountries.eu/data/gum.svg', + currency: 'United States dollar' + }, + { + name: 'Guatemala', + capital: 'Guatemala City', + languages: ['Spanish'], + population: 16176133, + flag: 'https://restcountries.eu/data/gtm.svg', + currency: 'Guatemalan quetzal' + }, + { + name: 'Guernsey', + capital: 'St. Peter Port', + languages: ['English', 'French'], + population: 62999, + flag: 'https://restcountries.eu/data/ggy.svg', + currency: 'British pound' + }, + { + name: 'Guinea', + capital: 'Conakry', + languages: ['French', 'Fula'], + population: 12947000, + flag: 'https://restcountries.eu/data/gin.svg', + currency: 'Guinean franc' + }, + { + name: 'Guinea-Bissau', + capital: 'Bissau', + languages: ['Portuguese'], + population: 1547777, + flag: 'https://restcountries.eu/data/gnb.svg', + currency: 'West African CFA franc' + }, + { + name: 'Guyana', + capital: 'Georgetown', + languages: ['English'], + population: 746900, + flag: 'https://restcountries.eu/data/guy.svg', + currency: 'Guyanese dollar' + }, + { + name: 'Haiti', + capital: 'Port-au-Prince', + languages: ['French', 'Haitian'], + population: 11078033, + flag: 'https://restcountries.eu/data/hti.svg', + currency: 'Haitian gourde' + }, + { + name: 'Heard Island and McDonald Islands', + capital: '', + languages: ['English'], + population: 0, + flag: 'https://restcountries.eu/data/hmd.svg', + currency: 'Australian dollar' + }, + { + name: 'Holy See', + capital: 'Rome', + languages: ['Latin', 'Italian', 'French', 'German'], + population: 451, + flag: 'https://restcountries.eu/data/vat.svg', + currency: 'Euro' + }, + { + name: 'Honduras', + capital: 'Tegucigalpa', + languages: ['Spanish'], + population: 8576532, + flag: 'https://restcountries.eu/data/hnd.svg', + currency: 'Honduran lempira' + }, + { + name: 'Hong Kong', + capital: 'City of Victoria', + languages: ['English', 'Chinese'], + population: 7324300, + flag: 'https://restcountries.eu/data/hkg.svg', + currency: 'Hong Kong dollar' + }, + { + name: 'Hungary', + capital: 'Budapest', + languages: ['Hungarian'], + population: 9823000, + flag: 'https://restcountries.eu/data/hun.svg', + currency: 'Hungarian forint' + }, + { + name: 'Iceland', + capital: 'Reykjavík', + languages: ['Icelandic'], + population: 334300, + flag: 'https://restcountries.eu/data/isl.svg', + currency: 'Icelandic króna' + }, + { + name: 'India', + capital: 'New Delhi', + languages: ['Hindi', 'English'], + population: 1295210000, + flag: 'https://restcountries.eu/data/ind.svg', + currency: 'Indian rupee' + }, + { + name: 'Indonesia', + capital: 'Jakarta', + languages: ['Indonesian'], + population: 258705000, + flag: 'https://restcountries.eu/data/idn.svg', + currency: 'Indonesian rupiah' + }, + { + name: "Côte d'Ivoire", + capital: 'Yamoussoukro', + languages: ['French'], + population: 22671331, + flag: 'https://restcountries.eu/data/civ.svg', + currency: 'West African CFA franc' + }, + { + name: 'Iran (Islamic Republic of)', + capital: 'Tehran', + languages: ['Persian (Farsi)'], + population: 79369900, + flag: 'https://restcountries.eu/data/irn.svg', + currency: 'Iranian rial' + }, + { + name: 'Iraq', + capital: 'Baghdad', + languages: ['Arabic', 'Kurdish'], + population: 37883543, + flag: 'https://restcountries.eu/data/irq.svg', + currency: 'Iraqi dinar' + }, + { + name: 'Ireland', + capital: 'Dublin', + languages: ['Irish', 'English'], + population: 6378000, + flag: 'https://restcountries.eu/data/irl.svg', + currency: 'Euro' + }, + { + name: 'Isle of Man', + capital: 'Douglas', + languages: ['English', 'Manx'], + population: 84497, + flag: 'https://restcountries.eu/data/imn.svg', + currency: 'British pound' + }, + { + name: 'Israel', + capital: 'Jerusalem', + languages: ['Hebrew (modern)', 'Arabic'], + population: 8527400, + flag: 'https://restcountries.eu/data/isr.svg', + currency: 'Israeli new shekel' + }, + { + name: 'Italy', + capital: 'Rome', + languages: ['Italian'], + population: 60665551, + flag: 'https://restcountries.eu/data/ita.svg', + currency: 'Euro' + }, + { + name: 'Jamaica', + capital: 'Kingston', + languages: ['English'], + population: 2723246, + flag: 'https://restcountries.eu/data/jam.svg', + currency: 'Jamaican dollar' + }, + { + name: 'Japan', + capital: 'Tokyo', + languages: ['Japanese'], + population: 126960000, + flag: 'https://restcountries.eu/data/jpn.svg', + currency: 'Japanese yen' + }, + { + name: 'Jersey', + capital: 'Saint Helier', + languages: ['English', 'French'], + population: 100800, + flag: 'https://restcountries.eu/data/jey.svg', + currency: 'British pound' + }, + { + name: 'Jordan', + capital: 'Amman', + languages: ['Arabic'], + population: 9531712, + flag: 'https://restcountries.eu/data/jor.svg', + currency: 'Jordanian dinar' + }, + { + name: 'Kazakhstan', + capital: 'Astana', + languages: ['Kazakh', 'Russian'], + population: 17753200, + flag: 'https://restcountries.eu/data/kaz.svg', + currency: 'Kazakhstani tenge' + }, + { + name: 'Kenya', + capital: 'Nairobi', + languages: ['English', 'Swahili'], + population: 47251000, + flag: 'https://restcountries.eu/data/ken.svg', + currency: 'Kenyan shilling' + }, + { + name: 'Kiribati', + capital: 'South Tarawa', + languages: ['English'], + population: 113400, + flag: 'https://restcountries.eu/data/kir.svg', + currency: 'Australian dollar' + }, + { + name: 'Kuwait', + capital: 'Kuwait City', + languages: ['Arabic'], + population: 4183658, + flag: 'https://restcountries.eu/data/kwt.svg', + currency: 'Kuwaiti dinar' + }, + { + name: 'Kyrgyzstan', + capital: 'Bishkek', + languages: ['Kyrgyz', 'Russian'], + population: 6047800, + flag: 'https://restcountries.eu/data/kgz.svg', + currency: 'Kyrgyzstani som' + }, + { + name: "Lao People's Democratic Republic", + capital: 'Vientiane', + languages: ['Lao'], + population: 6492400, + flag: 'https://restcountries.eu/data/lao.svg', + currency: 'Lao kip' + }, + { + name: 'Latvia', + capital: 'Riga', + languages: ['Latvian'], + population: 1961600, + flag: 'https://restcountries.eu/data/lva.svg', + currency: 'Euro' + }, + { + name: 'Lebanon', + capital: 'Beirut', + languages: ['Arabic', 'French'], + population: 5988000, + flag: 'https://restcountries.eu/data/lbn.svg', + currency: 'Lebanese pound' + }, + { + name: 'Lesotho', + capital: 'Maseru', + languages: ['English', 'Southern Sotho'], + population: 1894194, + flag: 'https://restcountries.eu/data/lso.svg', + currency: 'Lesotho loti' + }, + { + name: 'Liberia', + capital: 'Monrovia', + languages: ['English'], + population: 4615000, + flag: 'https://restcountries.eu/data/lbr.svg', + currency: 'Liberian dollar' + }, + { + name: 'Libya', + capital: 'Tripoli', + languages: ['Arabic'], + population: 6385000, + flag: 'https://restcountries.eu/data/lby.svg', + currency: 'Libyan dinar' + }, + { + name: 'Liechtenstein', + capital: 'Vaduz', + languages: ['German'], + population: 37623, + flag: 'https://restcountries.eu/data/lie.svg', + currency: 'Swiss franc' + }, + { + name: 'Lithuania', + capital: 'Vilnius', + languages: ['Lithuanian'], + population: 2872294, + flag: 'https://restcountries.eu/data/ltu.svg', + currency: 'Euro' + }, + { + name: 'Luxembourg', + capital: 'Luxembourg', + languages: ['French', 'German', 'Luxembourgish'], + population: 576200, + flag: 'https://restcountries.eu/data/lux.svg', + currency: 'Euro' + }, + { + name: 'Macao', + capital: '', + languages: ['Chinese', 'Portuguese'], + population: 649100, + flag: 'https://restcountries.eu/data/mac.svg', + currency: 'Macanese pataca' + }, + { + name: 'Macedonia (the former Yugoslav Republic of)', + capital: 'Skopje', + languages: ['Macedonian'], + population: 2058539, + flag: 'https://restcountries.eu/data/mkd.svg', + currency: 'Macedonian denar' + }, + { + name: 'Madagascar', + capital: 'Antananarivo', + languages: ['French', 'Malagasy'], + population: 22434363, + flag: 'https://restcountries.eu/data/mdg.svg', + currency: 'Malagasy ariary' + }, + { + name: 'Malawi', + capital: 'Lilongwe', + languages: ['English', 'Chichewa'], + population: 16832910, + flag: 'https://restcountries.eu/data/mwi.svg', + currency: 'Malawian kwacha' + }, + { + name: 'Malaysia', + capital: 'Kuala Lumpur', + languages: ['Malaysian'], + population: 31405416, + flag: 'https://restcountries.eu/data/mys.svg', + currency: 'Malaysian ringgit' + }, + { + name: 'Maldives', + capital: 'Malé', + languages: ['Divehi'], + population: 344023, + flag: 'https://restcountries.eu/data/mdv.svg', + currency: 'Maldivian rufiyaa' + }, + { + name: 'Mali', + capital: 'Bamako', + languages: ['French'], + population: 18135000, + flag: 'https://restcountries.eu/data/mli.svg', + currency: 'West African CFA franc' + }, + { + name: 'Malta', + capital: 'Valletta', + languages: ['Maltese', 'English'], + population: 425384, + flag: 'https://restcountries.eu/data/mlt.svg', + currency: 'Euro' + }, + { + name: 'Marshall Islands', + capital: 'Majuro', + languages: ['English', 'Marshallese'], + population: 54880, + flag: 'https://restcountries.eu/data/mhl.svg', + currency: 'United States dollar' + }, + { + name: 'Martinique', + capital: 'Fort-de-France', + languages: ['French'], + population: 378243, + flag: 'https://restcountries.eu/data/mtq.svg', + currency: 'Euro' + }, + { + name: 'Mauritania', + capital: 'Nouakchott', + languages: ['Arabic'], + population: 3718678, + flag: 'https://restcountries.eu/data/mrt.svg', + currency: 'Mauritanian ouguiya' + }, + { + name: 'Mauritius', + capital: 'Port Louis', + languages: ['English'], + population: 1262879, + flag: 'https://restcountries.eu/data/mus.svg', + currency: 'Mauritian rupee' + }, + { + name: 'Mayotte', + capital: 'Mamoudzou', + languages: ['French'], + population: 226915, + flag: 'https://restcountries.eu/data/myt.svg', + currency: 'Euro' + }, + { + name: 'Mexico', + capital: 'Mexico City', + languages: ['Spanish'], + population: 122273473, + flag: 'https://restcountries.eu/data/mex.svg', + currency: 'Mexican peso' + }, + { + name: 'Micronesia (Federated States of)', + capital: 'Palikir', + languages: ['English'], + population: 102800, + flag: 'https://restcountries.eu/data/fsm.svg', + currency: '[D]' + }, + { + name: 'Moldova (Republic of)', + capital: 'Chișinău', + languages: ['Romanian'], + population: 3553100, + flag: 'https://restcountries.eu/data/mda.svg', + currency: 'Moldovan leu' + }, + { + name: 'Monaco', + capital: 'Monaco', + languages: ['French'], + population: 38400, + flag: 'https://restcountries.eu/data/mco.svg', + currency: 'Euro' + }, + { + name: 'Mongolia', + capital: 'Ulan Bator', + languages: ['Mongolian'], + population: 3093100, + flag: 'https://restcountries.eu/data/mng.svg', + currency: 'Mongolian tögrög' + }, + { + name: 'Montenegro', + capital: 'Podgorica', + languages: ['Serbian', 'Bosnian', 'Albanian', 'Croatian'], + population: 621810, + flag: 'https://restcountries.eu/data/mne.svg', + currency: 'Euro' + }, + { + name: 'Montserrat', + capital: 'Plymouth', + languages: ['English'], + population: 4922, + flag: 'https://restcountries.eu/data/msr.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Morocco', + capital: 'Rabat', + languages: ['Arabic'], + population: 33337529, + flag: 'https://restcountries.eu/data/mar.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Mozambique', + capital: 'Maputo', + languages: ['Portuguese'], + population: 26423700, + flag: 'https://restcountries.eu/data/moz.svg', + currency: 'Mozambican metical' + }, + { + name: 'Myanmar', + capital: 'Naypyidaw', + languages: ['Burmese'], + population: 51419420, + flag: 'https://restcountries.eu/data/mmr.svg', + currency: 'Burmese kyat' + }, + { + name: 'Namibia', + capital: 'Windhoek', + languages: ['English', 'Afrikaans'], + population: 2324388, + flag: 'https://restcountries.eu/data/nam.svg', + currency: 'Namibian dollar' + }, + { + name: 'Nauru', + capital: 'Yaren', + languages: ['English', 'Nauruan'], + population: 10084, + flag: 'https://restcountries.eu/data/nru.svg', + currency: 'Australian dollar' + }, + { + name: 'Nepal', + capital: 'Kathmandu', + languages: ['Nepali'], + population: 28431500, + flag: 'https://restcountries.eu/data/npl.svg', + currency: 'Nepalese rupee' + }, + { + name: 'Netherlands', + capital: 'Amsterdam', + languages: ['Dutch'], + population: 17019800, + flag: 'https://restcountries.eu/data/nld.svg', + currency: 'Euro' + }, + { + name: 'New Caledonia', + capital: 'Nouméa', + languages: ['French'], + population: 268767, + flag: 'https://restcountries.eu/data/ncl.svg', + currency: 'CFP franc' + }, + { + name: 'New Zealand', + capital: 'Wellington', + languages: ['English', 'Māori'], + population: 4697854, + flag: 'https://restcountries.eu/data/nzl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Nicaragua', + capital: 'Managua', + languages: ['Spanish'], + population: 6262703, + flag: 'https://restcountries.eu/data/nic.svg', + currency: 'Nicaraguan córdoba' + }, + { + name: 'Niger', + capital: 'Niamey', + languages: ['French'], + population: 20715000, + flag: 'https://restcountries.eu/data/ner.svg', + currency: 'West African CFA franc' + }, + { + name: 'Nigeria', + capital: 'Abuja', + languages: ['English'], + population: 186988000, + flag: 'https://restcountries.eu/data/nga.svg', + currency: 'Nigerian naira' + }, + { + name: 'Niue', + capital: 'Alofi', + languages: ['English'], + population: 1470, + flag: 'https://restcountries.eu/data/niu.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Norfolk Island', + capital: 'Kingston', + languages: ['English'], + population: 2302, + flag: 'https://restcountries.eu/data/nfk.svg', + currency: 'Australian dollar' + }, + { + name: "Korea (Democratic People's Republic of)", + capital: 'Pyongyang', + languages: ['Korean'], + population: 25281000, + flag: 'https://restcountries.eu/data/prk.svg', + currency: 'North Korean won' + }, + { + name: 'Northern Mariana Islands', + capital: 'Saipan', + languages: ['English', 'Chamorro'], + population: 56940, + flag: 'https://restcountries.eu/data/mnp.svg', + currency: 'United States dollar' + }, + { + name: 'Norway', + capital: 'Oslo', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 5223256, + flag: 'https://restcountries.eu/data/nor.svg', + currency: 'Norwegian krone' + }, + { + name: 'Oman', + capital: 'Muscat', + languages: ['Arabic'], + population: 4420133, + flag: 'https://restcountries.eu/data/omn.svg', + currency: 'Omani rial' + }, + { + name: 'Pakistan', + capital: 'Islamabad', + languages: ['English', 'Urdu'], + population: 194125062, + flag: 'https://restcountries.eu/data/pak.svg', + currency: 'Pakistani rupee' + }, + { + name: 'Palau', + capital: 'Ngerulmud', + languages: ['English'], + population: 17950, + flag: 'https://restcountries.eu/data/plw.svg', + currency: '[E]' + }, + { + name: 'Palestine, State of', + capital: 'Ramallah', + languages: ['Arabic'], + population: 4682467, + flag: 'https://restcountries.eu/data/pse.svg', + currency: 'Israeli new sheqel' + }, + { + name: 'Panama', + capital: 'Panama City', + languages: ['Spanish'], + population: 3814672, + flag: 'https://restcountries.eu/data/pan.svg', + currency: 'Panamanian balboa' + }, + { + name: 'Papua New Guinea', + capital: 'Port Moresby', + languages: ['English'], + population: 8083700, + flag: 'https://restcountries.eu/data/png.svg', + currency: 'Papua New Guinean kina' + }, + { + name: 'Paraguay', + capital: 'Asunción', + languages: ['Spanish', 'Guaraní'], + population: 6854536, + flag: 'https://restcountries.eu/data/pry.svg', + currency: 'Paraguayan guaraní' + }, + { + name: 'Peru', + capital: 'Lima', + languages: ['Spanish'], + population: 31488700, + flag: 'https://restcountries.eu/data/per.svg', + currency: 'Peruvian sol' + }, + { + name: 'Philippines', + capital: 'Manila', + languages: ['English'], + population: 103279800, + flag: 'https://restcountries.eu/data/phl.svg', + currency: 'Philippine peso' + }, + { + name: 'Pitcairn', + capital: 'Adamstown', + languages: ['English'], + population: 56, + flag: 'https://restcountries.eu/data/pcn.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Poland', + capital: 'Warsaw', + languages: ['Polish'], + population: 38437239, + flag: 'https://restcountries.eu/data/pol.svg', + currency: 'Polish złoty' + }, + { + name: 'Portugal', + capital: 'Lisbon', + languages: ['Portuguese'], + population: 10374822, + flag: 'https://restcountries.eu/data/prt.svg', + currency: 'Euro' + }, + { + name: 'Puerto Rico', + capital: 'San Juan', + languages: ['Spanish', 'English'], + population: 3474182, + flag: 'https://restcountries.eu/data/pri.svg', + currency: 'United States dollar' + }, + { + name: 'Qatar', + capital: 'Doha', + languages: ['Arabic'], + population: 2587564, + flag: 'https://restcountries.eu/data/qat.svg', + currency: 'Qatari riyal' + }, + { + name: 'Republic of Kosovo', + capital: 'Pristina', + languages: ['Albanian', 'Serbian'], + population: 1733842, + flag: 'https://restcountries.eu/data/kos.svg', + currency: 'Euro' + }, + { + name: 'Réunion', + capital: 'Saint-Denis', + languages: ['French'], + population: 840974, + flag: 'https://restcountries.eu/data/reu.svg', + currency: 'Euro' + }, + { + name: 'Romania', + capital: 'Bucharest', + languages: ['Romanian'], + population: 19861408, + flag: 'https://restcountries.eu/data/rou.svg', + currency: 'Romanian leu' + }, + { + name: 'Russian Federation', + capital: 'Moscow', + languages: ['Russian'], + population: 146599183, + flag: 'https://restcountries.eu/data/rus.svg', + currency: 'Russian ruble' + }, + { + name: 'Rwanda', + capital: 'Kigali', + languages: ['Kinyarwanda', 'English', 'French'], + population: 11553188, + flag: 'https://restcountries.eu/data/rwa.svg', + currency: 'Rwandan franc' + }, + { + name: 'Saint Barthélemy', + capital: 'Gustavia', + languages: ['French'], + population: 9417, + flag: 'https://restcountries.eu/data/blm.svg', + currency: 'Euro' + }, + { + name: 'Saint Helena, Ascension and Tristan da Cunha', + capital: 'Jamestown', + languages: ['English'], + population: 4255, + flag: 'https://restcountries.eu/data/shn.svg', + currency: 'Saint Helena pound' + }, + { + name: 'Saint Kitts and Nevis', + capital: 'Basseterre', + languages: ['English'], + population: 46204, + flag: 'https://restcountries.eu/data/kna.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Lucia', + capital: 'Castries', + languages: ['English'], + population: 186000, + flag: 'https://restcountries.eu/data/lca.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Martin (French part)', + capital: 'Marigot', + languages: ['English', 'French', 'Dutch'], + population: 36979, + flag: 'https://restcountries.eu/data/maf.svg', + currency: 'Euro' + }, + { + name: 'Saint Pierre and Miquelon', + capital: 'Saint-Pierre', + languages: ['French'], + population: 6069, + flag: 'https://restcountries.eu/data/spm.svg', + currency: 'Euro' + }, + { + name: 'Saint Vincent and the Grenadines', + capital: 'Kingstown', + languages: ['English'], + population: 109991, + flag: 'https://restcountries.eu/data/vct.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Samoa', + capital: 'Apia', + languages: ['Samoan', 'English'], + population: 194899, + flag: 'https://restcountries.eu/data/wsm.svg', + currency: 'Samoan tālā' + }, + { + name: 'San Marino', + capital: 'City of San Marino', + languages: ['Italian'], + population: 33005, + flag: 'https://restcountries.eu/data/smr.svg', + currency: 'Euro' + }, + { + name: 'Sao Tome and Principe', + capital: 'São Tomé', + languages: ['Portuguese'], + population: 187356, + flag: 'https://restcountries.eu/data/stp.svg', + currency: 'São Tomé and Príncipe dobra' + }, + { + name: 'Saudi Arabia', + capital: 'Riyadh', + languages: ['Arabic'], + population: 32248200, + flag: 'https://restcountries.eu/data/sau.svg', + currency: 'Saudi riyal' + }, + { + name: 'Senegal', + capital: 'Dakar', + languages: ['French'], + population: 14799859, + flag: 'https://restcountries.eu/data/sen.svg', + currency: 'West African CFA franc' + }, + { + name: 'Serbia', + capital: 'Belgrade', + languages: ['Serbian'], + population: 7076372, + flag: 'https://restcountries.eu/data/srb.svg', + currency: 'Serbian dinar' + }, + { + name: 'Seychelles', + capital: 'Victoria', + languages: ['French', 'English'], + population: 91400, + flag: 'https://restcountries.eu/data/syc.svg', + currency: 'Seychellois rupee' + }, + { + name: 'Sierra Leone', + capital: 'Freetown', + languages: ['English'], + population: 7075641, + flag: 'https://restcountries.eu/data/sle.svg', + currency: 'Sierra Leonean leone' + }, + { + name: 'Singapore', + capital: 'Singapore', + languages: ['English', 'Malay', 'Tamil', 'Chinese'], + population: 5535000, + flag: 'https://restcountries.eu/data/sgp.svg', + currency: 'Brunei dollar' + }, + { + name: 'Sint Maarten (Dutch part)', + capital: 'Philipsburg', + languages: ['Dutch', 'English'], + population: 38247, + flag: 'https://restcountries.eu/data/sxm.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Slovakia', + capital: 'Bratislava', + languages: ['Slovak'], + population: 5426252, + flag: 'https://restcountries.eu/data/svk.svg', + currency: 'Euro' + }, + { + name: 'Slovenia', + capital: 'Ljubljana', + languages: ['Slovene'], + population: 2064188, + flag: 'https://restcountries.eu/data/svn.svg', + currency: 'Euro' + }, + { + name: 'Solomon Islands', + capital: 'Honiara', + languages: ['English'], + population: 642000, + flag: 'https://restcountries.eu/data/slb.svg', + currency: 'Solomon Islands dollar' + }, + { + name: 'Somalia', + capital: 'Mogadishu', + languages: ['Somali', 'Arabic'], + population: 11079000, + flag: 'https://restcountries.eu/data/som.svg', + currency: 'Somali shilling' + }, + { + name: 'South Africa', + capital: 'Pretoria', + languages: [ + 'Afrikaans', + 'English', + 'Southern Ndebele', + 'Southern Sotho', + 'Swati', + 'Tswana', + 'Tsonga', + 'Venda', + 'Xhosa', + 'Zulu' + ], + population: 55653654, + flag: 'https://restcountries.eu/data/zaf.svg', + currency: 'South African rand' + }, + { + name: 'South Georgia and the South Sandwich Islands', + capital: 'King Edward Point', + languages: ['English'], + population: 30, + flag: 'https://restcountries.eu/data/sgs.svg', + currency: 'British pound' + }, + { + name: 'Korea (Republic of)', + capital: 'Seoul', + languages: ['Korean'], + population: 50801405, + flag: 'https://restcountries.eu/data/kor.svg', + currency: 'South Korean won' + }, + { + name: 'South Sudan', + capital: 'Juba', + languages: ['English'], + population: 12131000, + flag: 'https://restcountries.eu/data/ssd.svg', + currency: 'South Sudanese pound' + }, + { + name: 'Spain', + capital: 'Madrid', + languages: ['Spanish'], + population: 46438422, + flag: 'https://restcountries.eu/data/esp.svg', + currency: 'Euro' + }, + { + name: 'Sri Lanka', + capital: 'Colombo', + languages: ['Sinhalese', 'Tamil'], + population: 20966000, + flag: 'https://restcountries.eu/data/lka.svg', + currency: 'Sri Lankan rupee' + }, + { + name: 'Sudan', + capital: 'Khartoum', + languages: ['Arabic', 'English'], + population: 39598700, + flag: 'https://restcountries.eu/data/sdn.svg', + currency: 'Sudanese pound' + }, + { + name: 'Suriname', + capital: 'Paramaribo', + languages: ['Dutch'], + population: 541638, + flag: 'https://restcountries.eu/data/sur.svg', + currency: 'Surinamese dollar' + }, + { + name: 'Svalbard and Jan Mayen', + capital: 'Longyearbyen', + languages: ['Norwegian'], + population: 2562, + flag: 'https://restcountries.eu/data/sjm.svg', + currency: 'Norwegian krone' + }, + { + name: 'Swaziland', + capital: 'Lobamba', + languages: ['English', 'Swati'], + population: 1132657, + flag: 'https://restcountries.eu/data/swz.svg', + currency: 'Swazi lilangeni' + }, + { + name: 'Sweden', + capital: 'Stockholm', + languages: ['Swedish'], + population: 9894888, + flag: 'https://restcountries.eu/data/swe.svg', + currency: 'Swedish krona' + }, + { + name: 'Switzerland', + capital: 'Bern', + languages: ['German', 'French', 'Italian'], + population: 8341600, + flag: 'https://restcountries.eu/data/che.svg', + currency: 'Swiss franc' + }, + { + name: 'Syrian Arab Republic', + capital: 'Damascus', + languages: ['Arabic'], + population: 18564000, + flag: 'https://restcountries.eu/data/syr.svg', + currency: 'Syrian pound' + }, + { + name: 'Taiwan', + capital: 'Taipei', + languages: ['Chinese'], + population: 23503349, + flag: 'https://restcountries.eu/data/twn.svg', + currency: 'New Taiwan dollar' + }, + { + name: 'Tajikistan', + capital: 'Dushanbe', + languages: ['Tajik', 'Russian'], + population: 8593600, + flag: 'https://restcountries.eu/data/tjk.svg', + currency: 'Tajikistani somoni' + }, + { + name: 'Tanzania, United Republic of', + capital: 'Dodoma', + languages: ['Swahili', 'English'], + population: 55155000, + flag: 'https://restcountries.eu/data/tza.svg', + currency: 'Tanzanian shilling' + }, + { + name: 'Thailand', + capital: 'Bangkok', + languages: ['Thai'], + population: 65327652, + flag: 'https://restcountries.eu/data/tha.svg', + currency: 'Thai baht' + }, + { + name: 'Timor-Leste', + capital: 'Dili', + languages: ['Portuguese'], + population: 1167242, + flag: 'https://restcountries.eu/data/tls.svg', + currency: 'United States dollar' + }, + { + name: 'Togo', + capital: 'Lomé', + languages: ['French'], + population: 7143000, + flag: 'https://restcountries.eu/data/tgo.svg', + currency: 'West African CFA franc' + }, + { + name: 'Tokelau', + capital: 'Fakaofo', + languages: ['English'], + population: 1411, + flag: 'https://restcountries.eu/data/tkl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Tonga', + capital: "Nuku'alofa", + languages: ['English', 'Tonga (Tonga Islands)'], + population: 103252, + flag: 'https://restcountries.eu/data/ton.svg', + currency: 'Tongan paʻanga' + }, + { + name: 'Trinidad and Tobago', + capital: 'Port of Spain', + languages: ['English'], + population: 1349667, + flag: 'https://restcountries.eu/data/tto.svg', + currency: 'Trinidad and Tobago dollar' + }, + { + name: 'Tunisia', + capital: 'Tunis', + languages: ['Arabic'], + population: 11154400, + flag: 'https://restcountries.eu/data/tun.svg', + currency: 'Tunisian dinar' + }, + { + name: 'Turkey', + capital: 'Ankara', + languages: ['Turkish'], + population: 78741053, + flag: 'https://restcountries.eu/data/tur.svg', + currency: 'Turkish lira' + }, + { + name: 'Turkmenistan', + capital: 'Ashgabat', + languages: ['Turkmen', 'Russian'], + population: 4751120, + flag: 'https://restcountries.eu/data/tkm.svg', + currency: 'Turkmenistan manat' + }, + { + name: 'Turks and Caicos Islands', + capital: 'Cockburn Town', + languages: ['English'], + population: 31458, + flag: 'https://restcountries.eu/data/tca.svg', + currency: 'United States dollar' + }, + { + name: 'Tuvalu', + capital: 'Funafuti', + languages: ['English'], + population: 10640, + flag: 'https://restcountries.eu/data/tuv.svg', + currency: 'Australian dollar' + }, + { + name: 'Uganda', + capital: 'Kampala', + languages: ['English', 'Swahili'], + population: 33860700, + flag: 'https://restcountries.eu/data/uga.svg', + currency: 'Ugandan shilling' + }, + { + name: 'Ukraine', + capital: 'Kiev', + languages: ['Ukrainian'], + population: 42692393, + flag: 'https://restcountries.eu/data/ukr.svg', + currency: 'Ukrainian hryvnia' + }, + { + name: 'United Arab Emirates', + capital: 'Abu Dhabi', + languages: ['Arabic'], + population: 9856000, + flag: 'https://restcountries.eu/data/are.svg', + currency: 'United Arab Emirates dirham' + }, + { + name: 'United Kingdom of Great Britain and Northern Ireland', + capital: 'London', + languages: ['English'], + population: 65110000, + flag: 'https://restcountries.eu/data/gbr.svg', + currency: 'British pound' + }, + { + name: 'United States of America', + capital: 'Washington, D.C.', + languages: ['English'], + population: 323947000, + flag: 'https://restcountries.eu/data/usa.svg', + currency: 'United States dollar' + }, + { + name: 'Uruguay', + capital: 'Montevideo', + languages: ['Spanish'], + population: 3480222, + flag: 'https://restcountries.eu/data/ury.svg', + currency: 'Uruguayan peso' + }, + { + name: 'Uzbekistan', + capital: 'Tashkent', + languages: ['Uzbek', 'Russian'], + population: 31576400, + flag: 'https://restcountries.eu/data/uzb.svg', + currency: "Uzbekistani so'm" + }, + { + name: 'Vanuatu', + capital: 'Port Vila', + languages: ['Bislama', 'English', 'French'], + population: 277500, + flag: 'https://restcountries.eu/data/vut.svg', + currency: 'Vanuatu vatu' + }, + { + name: 'Venezuela (Bolivarian Republic of)', + capital: 'Caracas', + languages: ['Spanish'], + population: 31028700, + flag: 'https://restcountries.eu/data/ven.svg', + currency: 'Venezuelan bolívar' + }, + { + name: 'Viet Nam', + capital: 'Hanoi', + languages: ['Vietnamese'], + population: 92700000, + flag: 'https://restcountries.eu/data/vnm.svg', + currency: 'Vietnamese đồng' + }, + { + name: 'Wallis and Futuna', + capital: 'Mata-Utu', + languages: ['French'], + population: 11750, + flag: 'https://restcountries.eu/data/wlf.svg', + currency: 'CFP franc' + }, + { + name: 'Western Sahara', + capital: 'El Aaiún', + languages: ['Spanish'], + population: 510713, + flag: 'https://restcountries.eu/data/esh.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Yemen', + capital: "Sana'a", + languages: ['Arabic'], + population: 27478000, + flag: 'https://restcountries.eu/data/yem.svg', + currency: 'Yemeni rial' + }, + { + name: 'Zambia', + capital: 'Lusaka', + languages: ['English'], + population: 15933883, + flag: 'https://restcountries.eu/data/zmb.svg', + currency: 'Zambian kwacha' + }, + { + name: 'Zimbabwe', + capital: 'Harare', + languages: ['English', 'Shona', 'Northern Ndebele'], + population: 14240168, + flag: 'https://restcountries.eu/data/zwe.svg', + currency: 'Botswana pula' + } +] diff --git a/13_Day_Console_object_methods/13_day_starter/index.html b/13_Day_Console_object_methods/13_day_starter/index.html new file mode 100644 index 0000000..977daaf --- /dev/null +++ b/13_Day_Console_object_methods/13_day_starter/index.html @@ -0,0 +1,17 @@ + + + + + 30DaysOfJavaScript:13 Day + + + +

30DaysOfJavaScript:13 Day

+

Console Object Methods

+ + + + + + + \ No newline at end of file diff --git a/13_Day_Console_object_methods/13_day_starter/scripts/main.js b/13_Day_Console_object_methods/13_day_starter/scripts/main.js new file mode 100644 index 0000000..c6045c8 --- /dev/null +++ b/13_Day_Console_object_methods/13_day_starter/scripts/main.js @@ -0,0 +1,2 @@ +console.log(countries) +alert('Open the console and check if the countries has been loaded') \ No newline at end of file diff --git a/14_Day_Error_handling/14_day_error_handling.md b/14_Day_Error_handling/14_day_error_handling.md new file mode 100644 index 0000000..696db4a --- /dev/null +++ b/14_Day_Error_handling/14_day_error_handling.md @@ -0,0 +1,193 @@ +
+

30 Days Of JavaScript: Error handling

+ + + + + Twitter Follow + + +Author: +Asabeneh Yetayeh
+ January, 2020 +
+ +
+ +[<< Day 13](../13_Day_Console_object_methods/13_day_console_object_methods.md) | [Day 15>>](../15_Day_Classes/15_day_classes.md) + +![Thirty Days Of JavaScript](../images/banners/day_1_14.png) + +- [Day 14](#day-14) + - [Error Handling](#error-handling) + - [Error Types](#error-types) + - [Exercises](#exercises) + - [Exercises:Level 1](#exerciseslevel-1) + - [Exercises: Level 2](#exercises-level-2) + - [Exercises:Level](#exerciseslevel) + +# Day 14 + +## Error Handling + +JavaScript is a loosely-typed language. Some times you will get a runtime error when you try to access an undefined variable or call undefined function etc. + +JavaScript similar to python or Java provides an error-handling mechanism to catch runtime errors using try-catch-finally block. + +```js +try { + // code that may throw an error +} catch (err) { + // code to be executed if an error occurs +} finally { + // code to be executed regardless of an error occurs or not +} +``` + +**try**: wrap suspicious code that may throw an error in try block.The try statement allows us to define a block of code to be tested for errors while it is being executed. + +**catch**: write code to do something in catch block when an error occurs. The catch block can have parameters that will give you error information. Catch block is used to log an error or display specific messages to the user. + +**finally**: finally block will always be executed regardless of the occurrence of an error. The finally block can be used to complete the remaining task or reset variables that might have changed before error occurred in try block. + +**Example:** + +```js +try { + let lastName = 'Yetayeh' + let fullName = fistName + ' ' + lastName +} catch (err) { + console.log(err) +} +``` + +```sh +ReferenceError: fistName is not defined + at :4:20 +``` + +```js +try { + let lastName = 'Yetayeh' + let fullName = fistName + ' ' + lastName +} catch (err) { + console.error(err) // we can use console.log() or console.error() +} finally { + console.log('In any case I will be executed') +} +``` + +```sh +ReferenceError: fistName is not defined + at :4:20 +In any case I will be executed +``` + +The catch block take a parameter. It is common to pass e, err or error as a parameter to the catch block. This parameter is an object and it has name and message keys. Lets use the name and message. + +```js +try { + let lastName = 'Yetayeh' + let fullName = fistName + ' ' + lastName +} catch (err) { + console.log('Name of the error', err.name) + console.log('Error message', err.message) +} finally { + console.log('In any case I will be executed') +} +``` + +```sh +Name of the error ReferenceError +Error message fistName is not defined +In any case I will be executed +``` + +throw: the throw statement allows us to create a custom error. We can through a string, number, boolean or an object. Use the throw statement to throw an exception. When you throw an exception, expression specifies the value of the exception. Each of the following throws an exception: + +```js +throw 'Error2' // generates an exception with a string value +throw 42 // generates an exception with the value 42 +throw true // generates an exception with the value true +throw new Error('Required') // generates an error object with the message of Required +``` + +```js +const throwErroExampleFun = () => { + let message + let x = prompt('Enter a number: ') + try { + if (x == '') throw 'empty' + if (isNaN(x)) throw 'not a number' + x = Number(x) + if (x < 5) throw 'too low' + if (x > 10) throw 'too high' + } catch (err) { + console.log(err) + } +} +throwErroExampleFun() +``` + +### Error Types + +- ReferenceError: An illegal reference has occurred. A ReferenceError is thrown if we use a variable that has not been declared. + +```js +let firstName = 'Asabeneh' +let fullName = firstName + ' ' + lastName + +console.log(fullName) +``` + +```sh +Uncaught ReferenceError: lastName is not defined + at :2:35 +``` + +- SyntaxError: A syntax error has occurred + +```js +let square = 2 x 2 +console.log(square) + +console.log('Hello, world") +``` + +```sh +Uncaught SyntaxError: Unexpected identifier +``` + +- TypeError: A type error has occurred + +```js +let num = 10 +console.log(num.toLowerCase()) +``` + +```sh +Uncaught TypeError: num.toLowerCase is not a function + at :2:17 +``` + +These are some of the common error you may face when you write a code. Understanding errors can help you to know what mistakes you made and it will help you to debug your code fast. + +🌕 You are flawless. Now, you knew how to handle errors and you can write robust application which handle unexpected user inputs. You have just completed day 14 challenges and you are 14 steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle. + +## Exercises + +### Exercises:Level 1 + +Practice + +### Exercises: Level 2 + +Practice + +### Exercises:Level + +Practice + +🎉 CONGRATULATIONS ! 🎉 + +[<< Day 13](../13_Day_Console_object_methods/13_day_console_object_methods.md) | [Day 15>>](../15_Day_Classes/15_day_classes.md) diff --git a/14_Day_Error_handling/14_day_starter/data/countries_data.js b/14_Day_Error_handling/14_day_starter/data/countries_data.js new file mode 100644 index 0000000..92acddd --- /dev/null +++ b/14_Day_Error_handling/14_day_starter/data/countries_data.js @@ -0,0 +1,2013 @@ +const countries = [ + { + name: 'Afghanistan', + capital: 'Kabul', + languages: ['Pashto', 'Uzbek', 'Turkmen'], + population: 27657145, + flag: 'https://restcountries.eu/data/afg.svg', + currency: 'Afghan afghani' + }, + { + name: 'Åland Islands', + capital: 'Mariehamn', + languages: ['Swedish'], + population: 28875, + flag: 'https://restcountries.eu/data/ala.svg', + currency: 'Euro' + }, + { + name: 'Albania', + capital: 'Tirana', + languages: ['Albanian'], + population: 2886026, + flag: 'https://restcountries.eu/data/alb.svg', + currency: 'Albanian lek' + }, + { + name: 'Algeria', + capital: 'Algiers', + languages: ['Arabic'], + population: 40400000, + flag: 'https://restcountries.eu/data/dza.svg', + currency: 'Algerian dinar' + }, + { + name: 'American Samoa', + capital: 'Pago Pago', + languages: ['English', 'Samoan'], + population: 57100, + flag: 'https://restcountries.eu/data/asm.svg', + currency: 'United State Dollar' + }, + { + name: 'Andorra', + capital: 'Andorra la Vella', + languages: ['Catalan'], + population: 78014, + flag: 'https://restcountries.eu/data/and.svg', + currency: 'Euro' + }, + { + name: 'Angola', + capital: 'Luanda', + languages: ['Portuguese'], + population: 25868000, + flag: 'https://restcountries.eu/data/ago.svg', + currency: 'Angolan kwanza' + }, + { + name: 'Anguilla', + capital: 'The Valley', + languages: ['English'], + population: 13452, + flag: 'https://restcountries.eu/data/aia.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Antarctica', + capital: '', + languages: ['English', 'Russian'], + population: 1000, + flag: 'https://restcountries.eu/data/ata.svg', + currency: 'Australian dollar' + }, + { + name: 'Antigua and Barbuda', + capital: "Saint John's", + languages: ['English'], + population: 86295, + flag: 'https://restcountries.eu/data/atg.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Argentina', + capital: 'Buenos Aires', + languages: ['Spanish', 'Guaraní'], + population: 43590400, + flag: 'https://restcountries.eu/data/arg.svg', + currency: 'Argentine peso' + }, + { + name: 'Armenia', + capital: 'Yerevan', + languages: ['Armenian', 'Russian'], + population: 2994400, + flag: 'https://restcountries.eu/data/arm.svg', + currency: 'Armenian dram' + }, + { + name: 'Aruba', + capital: 'Oranjestad', + languages: ['Dutch', '(Eastern) Punjabi'], + population: 107394, + flag: 'https://restcountries.eu/data/abw.svg', + currency: 'Aruban florin' + }, + { + name: 'Australia', + capital: 'Canberra', + languages: ['English'], + population: 24117360, + flag: 'https://restcountries.eu/data/aus.svg', + currency: 'Australian dollar' + }, + { + name: 'Austria', + capital: 'Vienna', + languages: ['German'], + population: 8725931, + flag: 'https://restcountries.eu/data/aut.svg', + currency: 'Euro' + }, + { + name: 'Azerbaijan', + capital: 'Baku', + languages: ['Azerbaijani'], + population: 9730500, + flag: 'https://restcountries.eu/data/aze.svg', + currency: 'Azerbaijani manat' + }, + { + name: 'Bahamas', + capital: 'Nassau', + languages: ['English'], + population: 378040, + flag: 'https://restcountries.eu/data/bhs.svg', + currency: 'Bahamian dollar' + }, + { + name: 'Bahrain', + capital: 'Manama', + languages: ['Arabic'], + population: 1404900, + flag: 'https://restcountries.eu/data/bhr.svg', + currency: 'Bahraini dinar' + }, + { + name: 'Bangladesh', + capital: 'Dhaka', + languages: ['Bengali'], + population: 161006790, + flag: 'https://restcountries.eu/data/bgd.svg', + currency: 'Bangladeshi taka' + }, + { + name: 'Barbados', + capital: 'Bridgetown', + languages: ['English'], + population: 285000, + flag: 'https://restcountries.eu/data/brb.svg', + currency: 'Barbadian dollar' + }, + { + name: 'Belarus', + capital: 'Minsk', + languages: ['Belarusian', 'Russian'], + population: 9498700, + flag: 'https://restcountries.eu/data/blr.svg', + currency: 'New Belarusian ruble' + }, + { + name: 'Belgium', + capital: 'Brussels', + languages: ['Dutch', 'French', 'German'], + population: 11319511, + flag: 'https://restcountries.eu/data/bel.svg', + currency: 'Euro' + }, + { + name: 'Belize', + capital: 'Belmopan', + languages: ['English', 'Spanish'], + population: 370300, + flag: 'https://restcountries.eu/data/blz.svg', + currency: 'Belize dollar' + }, + { + name: 'Benin', + capital: 'Porto-Novo', + languages: ['French'], + population: 10653654, + flag: 'https://restcountries.eu/data/ben.svg', + currency: 'West African CFA franc' + }, + { + name: 'Bermuda', + capital: 'Hamilton', + languages: ['English'], + population: 61954, + flag: 'https://restcountries.eu/data/bmu.svg', + currency: 'Bermudian dollar' + }, + { + name: 'Bhutan', + capital: 'Thimphu', + languages: ['Dzongkha'], + population: 775620, + flag: 'https://restcountries.eu/data/btn.svg', + currency: 'Bhutanese ngultrum' + }, + { + name: 'Bolivia (Plurinational State of)', + capital: 'Sucre', + languages: ['Spanish', 'Aymara', 'Quechua'], + population: 10985059, + flag: 'https://restcountries.eu/data/bol.svg', + currency: 'Bolivian boliviano' + }, + { + name: 'Bonaire, Sint Eustatius and Saba', + capital: 'Kralendijk', + languages: ['Dutch'], + population: 17408, + flag: 'https://restcountries.eu/data/bes.svg', + currency: 'United States dollar' + }, + { + name: 'Bosnia and Herzegovina', + capital: 'Sarajevo', + languages: ['Bosnian', 'Croatian', 'Serbian'], + population: 3531159, + flag: 'https://restcountries.eu/data/bih.svg', + currency: 'Bosnia and Herzegovina convertible mark' + }, + { + name: 'Botswana', + capital: 'Gaborone', + languages: ['English', 'Tswana'], + population: 2141206, + flag: 'https://restcountries.eu/data/bwa.svg', + currency: 'Botswana pula' + }, + { + name: 'Bouvet Island', + capital: '', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 0, + flag: 'https://restcountries.eu/data/bvt.svg', + currency: 'Norwegian krone' + }, + { + name: 'Brazil', + capital: 'Brasília', + languages: ['Portuguese'], + population: 206135893, + flag: 'https://restcountries.eu/data/bra.svg', + currency: 'Brazilian real' + }, + { + name: 'British Indian Ocean Territory', + capital: 'Diego Garcia', + languages: ['English'], + population: 3000, + flag: 'https://restcountries.eu/data/iot.svg', + currency: 'United States dollar' + }, + { + name: 'United States Minor Outlying Islands', + capital: '', + languages: ['English'], + population: 300, + flag: 'https://restcountries.eu/data/umi.svg', + currency: 'United States Dollar' + }, + { + name: 'Virgin Islands (British)', + capital: 'Road Town', + languages: ['English'], + population: 28514, + flag: 'https://restcountries.eu/data/vgb.svg', + currency: '[D]' + }, + { + name: 'Virgin Islands (U.S.)', + capital: 'Charlotte Amalie', + languages: ['English'], + population: 114743, + flag: 'https://restcountries.eu/data/vir.svg', + currency: 'United States dollar' + }, + { + name: 'Brunei Darussalam', + capital: 'Bandar Seri Begawan', + languages: ['Malay'], + population: 411900, + flag: 'https://restcountries.eu/data/brn.svg', + currency: 'Brunei dollar' + }, + { + name: 'Bulgaria', + capital: 'Sofia', + languages: ['Bulgarian'], + population: 7153784, + flag: 'https://restcountries.eu/data/bgr.svg', + currency: 'Bulgarian lev' + }, + { + name: 'Burkina Faso', + capital: 'Ouagadougou', + languages: ['French', 'Fula'], + population: 19034397, + flag: 'https://restcountries.eu/data/bfa.svg', + currency: 'West African CFA franc' + }, + { + name: 'Burundi', + capital: 'Bujumbura', + languages: ['French', 'Kirundi'], + population: 10114505, + flag: 'https://restcountries.eu/data/bdi.svg', + currency: 'Burundian franc' + }, + { + name: 'Cambodia', + capital: 'Phnom Penh', + languages: ['Khmer'], + population: 15626444, + flag: 'https://restcountries.eu/data/khm.svg', + currency: 'Cambodian riel' + }, + { + name: 'Cameroon', + capital: 'Yaoundé', + languages: ['English', 'French'], + population: 22709892, + flag: 'https://restcountries.eu/data/cmr.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Canada', + capital: 'Ottawa', + languages: ['English', 'French'], + population: 36155487, + flag: 'https://restcountries.eu/data/can.svg', + currency: 'Canadian dollar' + }, + { + name: 'Cabo Verde', + capital: 'Praia', + languages: ['Portuguese'], + population: 531239, + flag: 'https://restcountries.eu/data/cpv.svg', + currency: 'Cape Verdean escudo' + }, + { + name: 'Cayman Islands', + capital: 'George Town', + languages: ['English'], + population: 58238, + flag: 'https://restcountries.eu/data/cym.svg', + currency: 'Cayman Islands dollar' + }, + { + name: 'Central African Republic', + capital: 'Bangui', + languages: ['French', 'Sango'], + population: 4998000, + flag: 'https://restcountries.eu/data/caf.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chad', + capital: "N'Djamena", + languages: ['French', 'Arabic'], + population: 14497000, + flag: 'https://restcountries.eu/data/tcd.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chile', + capital: 'Santiago', + languages: ['Spanish'], + population: 18191900, + flag: 'https://restcountries.eu/data/chl.svg', + currency: 'Chilean peso' + }, + { + name: 'China', + capital: 'Beijing', + languages: ['Chinese'], + population: 1377422166, + flag: 'https://restcountries.eu/data/chn.svg', + currency: 'Chinese yuan' + }, + { + name: 'Christmas Island', + capital: 'Flying Fish Cove', + languages: ['English'], + population: 2072, + flag: 'https://restcountries.eu/data/cxr.svg', + currency: 'Australian dollar' + }, + { + name: 'Cocos (Keeling) Islands', + capital: 'West Island', + languages: ['English'], + population: 550, + flag: 'https://restcountries.eu/data/cck.svg', + currency: 'Australian dollar' + }, + { + name: 'Colombia', + capital: 'Bogotá', + languages: ['Spanish'], + population: 48759958, + flag: 'https://restcountries.eu/data/col.svg', + currency: 'Colombian peso' + }, + { + name: 'Comoros', + capital: 'Moroni', + languages: ['Arabic', 'French'], + population: 806153, + flag: 'https://restcountries.eu/data/com.svg', + currency: 'Comorian franc' + }, + { + name: 'Congo', + capital: 'Brazzaville', + languages: ['French', 'Lingala'], + population: 4741000, + flag: 'https://restcountries.eu/data/cog.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Congo (Democratic Republic of the)', + capital: 'Kinshasa', + languages: ['French', 'Lingala', 'Kongo', 'Swahili', 'Luba-Katanga'], + population: 85026000, + flag: 'https://restcountries.eu/data/cod.svg', + currency: 'Congolese franc' + }, + { + name: 'Cook Islands', + capital: 'Avarua', + languages: ['English'], + population: 18100, + flag: 'https://restcountries.eu/data/cok.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Costa Rica', + capital: 'San José', + languages: ['Spanish'], + population: 4890379, + flag: 'https://restcountries.eu/data/cri.svg', + currency: 'Costa Rican colón' + }, + { + name: 'Croatia', + capital: 'Zagreb', + languages: ['Croatian'], + population: 4190669, + flag: 'https://restcountries.eu/data/hrv.svg', + currency: 'Croatian kuna' + }, + { + name: 'Cuba', + capital: 'Havana', + languages: ['Spanish'], + population: 11239004, + flag: 'https://restcountries.eu/data/cub.svg', + currency: 'Cuban convertible peso' + }, + { + name: 'Curaçao', + capital: 'Willemstad', + languages: ['Dutch', '(Eastern) Punjabi', 'English'], + population: 154843, + flag: 'https://restcountries.eu/data/cuw.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Cyprus', + capital: 'Nicosia', + languages: ['Greek (modern)', 'Turkish', 'Armenian'], + population: 847000, + flag: 'https://restcountries.eu/data/cyp.svg', + currency: 'Euro' + }, + { + name: 'Czech Republic', + capital: 'Prague', + languages: ['Czech', 'Slovak'], + population: 10558524, + flag: 'https://restcountries.eu/data/cze.svg', + currency: 'Czech koruna' + }, + { + name: 'Denmark', + capital: 'Copenhagen', + languages: ['Danish'], + population: 5717014, + flag: 'https://restcountries.eu/data/dnk.svg', + currency: 'Danish krone' + }, + { + name: 'Djibouti', + capital: 'Djibouti', + languages: ['French', 'Arabic'], + population: 900000, + flag: 'https://restcountries.eu/data/dji.svg', + currency: 'Djiboutian franc' + }, + { + name: 'Dominica', + capital: 'Roseau', + languages: ['English'], + population: 71293, + flag: 'https://restcountries.eu/data/dma.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Dominican Republic', + capital: 'Santo Domingo', + languages: ['Spanish'], + population: 10075045, + flag: 'https://restcountries.eu/data/dom.svg', + currency: 'Dominican peso' + }, + { + name: 'Ecuador', + capital: 'Quito', + languages: ['Spanish'], + population: 16545799, + flag: 'https://restcountries.eu/data/ecu.svg', + currency: 'United States dollar' + }, + { + name: 'Egypt', + capital: 'Cairo', + languages: ['Arabic'], + population: 91290000, + flag: 'https://restcountries.eu/data/egy.svg', + currency: 'Egyptian pound' + }, + { + name: 'El Salvador', + capital: 'San Salvador', + languages: ['Spanish'], + population: 6520675, + flag: 'https://restcountries.eu/data/slv.svg', + currency: 'United States dollar' + }, + { + name: 'Equatorial Guinea', + capital: 'Malabo', + languages: ['Spanish', 'French'], + population: 1222442, + flag: 'https://restcountries.eu/data/gnq.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Eritrea', + capital: 'Asmara', + languages: ['Tigrinya', 'Arabic', 'English'], + population: 5352000, + flag: 'https://restcountries.eu/data/eri.svg', + currency: 'Eritrean nakfa' + }, + { + name: 'Estonia', + capital: 'Tallinn', + languages: ['Estonian'], + population: 1315944, + flag: 'https://restcountries.eu/data/est.svg', + currency: 'Euro' + }, + { + name: 'Ethiopia', + capital: 'Addis Ababa', + languages: ['Amharic'], + population: 92206005, + flag: 'https://restcountries.eu/data/eth.svg', + currency: 'Ethiopian birr' + }, + { + name: 'Falkland Islands (Malvinas)', + capital: 'Stanley', + languages: ['English'], + population: 2563, + flag: 'https://restcountries.eu/data/flk.svg', + currency: 'Falkland Islands pound' + }, + { + name: 'Faroe Islands', + capital: 'Tórshavn', + languages: ['Faroese'], + population: 49376, + flag: 'https://restcountries.eu/data/fro.svg', + currency: 'Danish krone' + }, + { + name: 'Fiji', + capital: 'Suva', + languages: ['English', 'Fijian', 'Hindi', 'Urdu'], + population: 867000, + flag: 'https://restcountries.eu/data/fji.svg', + currency: 'Fijian dollar' + }, + { + name: 'Finland', + capital: 'Helsinki', + languages: ['Finnish', 'Swedish'], + population: 5491817, + flag: 'https://restcountries.eu/data/fin.svg', + currency: 'Euro' + }, + { + name: 'France', + capital: 'Paris', + languages: ['French'], + population: 66710000, + flag: 'https://restcountries.eu/data/fra.svg', + currency: 'Euro' + }, + { + name: 'French Guiana', + capital: 'Cayenne', + languages: ['French'], + population: 254541, + flag: 'https://restcountries.eu/data/guf.svg', + currency: 'Euro' + }, + { + name: 'French Polynesia', + capital: 'Papeetē', + languages: ['French'], + population: 271800, + flag: 'https://restcountries.eu/data/pyf.svg', + currency: 'CFP franc' + }, + { + name: 'French Southern Territories', + capital: 'Port-aux-Français', + languages: ['French'], + population: 140, + flag: 'https://restcountries.eu/data/atf.svg', + currency: 'Euro' + }, + { + name: 'Gabon', + capital: 'Libreville', + languages: ['French'], + population: 1802278, + flag: 'https://restcountries.eu/data/gab.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Gambia', + capital: 'Banjul', + languages: ['English'], + population: 1882450, + flag: 'https://restcountries.eu/data/gmb.svg', + currency: 'Gambian dalasi' + }, + { + name: 'Georgia', + capital: 'Tbilisi', + languages: ['Georgian'], + population: 3720400, + flag: 'https://restcountries.eu/data/geo.svg', + currency: 'Georgian Lari' + }, + { + name: 'Germany', + capital: 'Berlin', + languages: ['German'], + population: 81770900, + flag: 'https://restcountries.eu/data/deu.svg', + currency: 'Euro' + }, + { + name: 'Ghana', + capital: 'Accra', + languages: ['English'], + population: 27670174, + flag: 'https://restcountries.eu/data/gha.svg', + currency: 'Ghanaian cedi' + }, + { + name: 'Gibraltar', + capital: 'Gibraltar', + languages: ['English'], + population: 33140, + flag: 'https://restcountries.eu/data/gib.svg', + currency: 'Gibraltar pound' + }, + { + name: 'Greece', + capital: 'Athens', + languages: ['Greek (modern)'], + population: 10858018, + flag: 'https://restcountries.eu/data/grc.svg', + currency: 'Euro' + }, + { + name: 'Greenland', + capital: 'Nuuk', + languages: ['Kalaallisut'], + population: 55847, + flag: 'https://restcountries.eu/data/grl.svg', + currency: 'Danish krone' + }, + { + name: 'Grenada', + capital: "St. George's", + languages: ['English'], + population: 103328, + flag: 'https://restcountries.eu/data/grd.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Guadeloupe', + capital: 'Basse-Terre', + languages: ['French'], + population: 400132, + flag: 'https://restcountries.eu/data/glp.svg', + currency: 'Euro' + }, + { + name: 'Guam', + capital: 'Hagåtña', + languages: ['English', 'Chamorro', 'Spanish'], + population: 184200, + flag: 'https://restcountries.eu/data/gum.svg', + currency: 'United States dollar' + }, + { + name: 'Guatemala', + capital: 'Guatemala City', + languages: ['Spanish'], + population: 16176133, + flag: 'https://restcountries.eu/data/gtm.svg', + currency: 'Guatemalan quetzal' + }, + { + name: 'Guernsey', + capital: 'St. Peter Port', + languages: ['English', 'French'], + population: 62999, + flag: 'https://restcountries.eu/data/ggy.svg', + currency: 'British pound' + }, + { + name: 'Guinea', + capital: 'Conakry', + languages: ['French', 'Fula'], + population: 12947000, + flag: 'https://restcountries.eu/data/gin.svg', + currency: 'Guinean franc' + }, + { + name: 'Guinea-Bissau', + capital: 'Bissau', + languages: ['Portuguese'], + population: 1547777, + flag: 'https://restcountries.eu/data/gnb.svg', + currency: 'West African CFA franc' + }, + { + name: 'Guyana', + capital: 'Georgetown', + languages: ['English'], + population: 746900, + flag: 'https://restcountries.eu/data/guy.svg', + currency: 'Guyanese dollar' + }, + { + name: 'Haiti', + capital: 'Port-au-Prince', + languages: ['French', 'Haitian'], + population: 11078033, + flag: 'https://restcountries.eu/data/hti.svg', + currency: 'Haitian gourde' + }, + { + name: 'Heard Island and McDonald Islands', + capital: '', + languages: ['English'], + population: 0, + flag: 'https://restcountries.eu/data/hmd.svg', + currency: 'Australian dollar' + }, + { + name: 'Holy See', + capital: 'Rome', + languages: ['Latin', 'Italian', 'French', 'German'], + population: 451, + flag: 'https://restcountries.eu/data/vat.svg', + currency: 'Euro' + }, + { + name: 'Honduras', + capital: 'Tegucigalpa', + languages: ['Spanish'], + population: 8576532, + flag: 'https://restcountries.eu/data/hnd.svg', + currency: 'Honduran lempira' + }, + { + name: 'Hong Kong', + capital: 'City of Victoria', + languages: ['English', 'Chinese'], + population: 7324300, + flag: 'https://restcountries.eu/data/hkg.svg', + currency: 'Hong Kong dollar' + }, + { + name: 'Hungary', + capital: 'Budapest', + languages: ['Hungarian'], + population: 9823000, + flag: 'https://restcountries.eu/data/hun.svg', + currency: 'Hungarian forint' + }, + { + name: 'Iceland', + capital: 'Reykjavík', + languages: ['Icelandic'], + population: 334300, + flag: 'https://restcountries.eu/data/isl.svg', + currency: 'Icelandic króna' + }, + { + name: 'India', + capital: 'New Delhi', + languages: ['Hindi', 'English'], + population: 1295210000, + flag: 'https://restcountries.eu/data/ind.svg', + currency: 'Indian rupee' + }, + { + name: 'Indonesia', + capital: 'Jakarta', + languages: ['Indonesian'], + population: 258705000, + flag: 'https://restcountries.eu/data/idn.svg', + currency: 'Indonesian rupiah' + }, + { + name: "Côte d'Ivoire", + capital: 'Yamoussoukro', + languages: ['French'], + population: 22671331, + flag: 'https://restcountries.eu/data/civ.svg', + currency: 'West African CFA franc' + }, + { + name: 'Iran (Islamic Republic of)', + capital: 'Tehran', + languages: ['Persian (Farsi)'], + population: 79369900, + flag: 'https://restcountries.eu/data/irn.svg', + currency: 'Iranian rial' + }, + { + name: 'Iraq', + capital: 'Baghdad', + languages: ['Arabic', 'Kurdish'], + population: 37883543, + flag: 'https://restcountries.eu/data/irq.svg', + currency: 'Iraqi dinar' + }, + { + name: 'Ireland', + capital: 'Dublin', + languages: ['Irish', 'English'], + population: 6378000, + flag: 'https://restcountries.eu/data/irl.svg', + currency: 'Euro' + }, + { + name: 'Isle of Man', + capital: 'Douglas', + languages: ['English', 'Manx'], + population: 84497, + flag: 'https://restcountries.eu/data/imn.svg', + currency: 'British pound' + }, + { + name: 'Israel', + capital: 'Jerusalem', + languages: ['Hebrew (modern)', 'Arabic'], + population: 8527400, + flag: 'https://restcountries.eu/data/isr.svg', + currency: 'Israeli new shekel' + }, + { + name: 'Italy', + capital: 'Rome', + languages: ['Italian'], + population: 60665551, + flag: 'https://restcountries.eu/data/ita.svg', + currency: 'Euro' + }, + { + name: 'Jamaica', + capital: 'Kingston', + languages: ['English'], + population: 2723246, + flag: 'https://restcountries.eu/data/jam.svg', + currency: 'Jamaican dollar' + }, + { + name: 'Japan', + capital: 'Tokyo', + languages: ['Japanese'], + population: 126960000, + flag: 'https://restcountries.eu/data/jpn.svg', + currency: 'Japanese yen' + }, + { + name: 'Jersey', + capital: 'Saint Helier', + languages: ['English', 'French'], + population: 100800, + flag: 'https://restcountries.eu/data/jey.svg', + currency: 'British pound' + }, + { + name: 'Jordan', + capital: 'Amman', + languages: ['Arabic'], + population: 9531712, + flag: 'https://restcountries.eu/data/jor.svg', + currency: 'Jordanian dinar' + }, + { + name: 'Kazakhstan', + capital: 'Astana', + languages: ['Kazakh', 'Russian'], + population: 17753200, + flag: 'https://restcountries.eu/data/kaz.svg', + currency: 'Kazakhstani tenge' + }, + { + name: 'Kenya', + capital: 'Nairobi', + languages: ['English', 'Swahili'], + population: 47251000, + flag: 'https://restcountries.eu/data/ken.svg', + currency: 'Kenyan shilling' + }, + { + name: 'Kiribati', + capital: 'South Tarawa', + languages: ['English'], + population: 113400, + flag: 'https://restcountries.eu/data/kir.svg', + currency: 'Australian dollar' + }, + { + name: 'Kuwait', + capital: 'Kuwait City', + languages: ['Arabic'], + population: 4183658, + flag: 'https://restcountries.eu/data/kwt.svg', + currency: 'Kuwaiti dinar' + }, + { + name: 'Kyrgyzstan', + capital: 'Bishkek', + languages: ['Kyrgyz', 'Russian'], + population: 6047800, + flag: 'https://restcountries.eu/data/kgz.svg', + currency: 'Kyrgyzstani som' + }, + { + name: "Lao People's Democratic Republic", + capital: 'Vientiane', + languages: ['Lao'], + population: 6492400, + flag: 'https://restcountries.eu/data/lao.svg', + currency: 'Lao kip' + }, + { + name: 'Latvia', + capital: 'Riga', + languages: ['Latvian'], + population: 1961600, + flag: 'https://restcountries.eu/data/lva.svg', + currency: 'Euro' + }, + { + name: 'Lebanon', + capital: 'Beirut', + languages: ['Arabic', 'French'], + population: 5988000, + flag: 'https://restcountries.eu/data/lbn.svg', + currency: 'Lebanese pound' + }, + { + name: 'Lesotho', + capital: 'Maseru', + languages: ['English', 'Southern Sotho'], + population: 1894194, + flag: 'https://restcountries.eu/data/lso.svg', + currency: 'Lesotho loti' + }, + { + name: 'Liberia', + capital: 'Monrovia', + languages: ['English'], + population: 4615000, + flag: 'https://restcountries.eu/data/lbr.svg', + currency: 'Liberian dollar' + }, + { + name: 'Libya', + capital: 'Tripoli', + languages: ['Arabic'], + population: 6385000, + flag: 'https://restcountries.eu/data/lby.svg', + currency: 'Libyan dinar' + }, + { + name: 'Liechtenstein', + capital: 'Vaduz', + languages: ['German'], + population: 37623, + flag: 'https://restcountries.eu/data/lie.svg', + currency: 'Swiss franc' + }, + { + name: 'Lithuania', + capital: 'Vilnius', + languages: ['Lithuanian'], + population: 2872294, + flag: 'https://restcountries.eu/data/ltu.svg', + currency: 'Euro' + }, + { + name: 'Luxembourg', + capital: 'Luxembourg', + languages: ['French', 'German', 'Luxembourgish'], + population: 576200, + flag: 'https://restcountries.eu/data/lux.svg', + currency: 'Euro' + }, + { + name: 'Macao', + capital: '', + languages: ['Chinese', 'Portuguese'], + population: 649100, + flag: 'https://restcountries.eu/data/mac.svg', + currency: 'Macanese pataca' + }, + { + name: 'Macedonia (the former Yugoslav Republic of)', + capital: 'Skopje', + languages: ['Macedonian'], + population: 2058539, + flag: 'https://restcountries.eu/data/mkd.svg', + currency: 'Macedonian denar' + }, + { + name: 'Madagascar', + capital: 'Antananarivo', + languages: ['French', 'Malagasy'], + population: 22434363, + flag: 'https://restcountries.eu/data/mdg.svg', + currency: 'Malagasy ariary' + }, + { + name: 'Malawi', + capital: 'Lilongwe', + languages: ['English', 'Chichewa'], + population: 16832910, + flag: 'https://restcountries.eu/data/mwi.svg', + currency: 'Malawian kwacha' + }, + { + name: 'Malaysia', + capital: 'Kuala Lumpur', + languages: ['Malaysian'], + population: 31405416, + flag: 'https://restcountries.eu/data/mys.svg', + currency: 'Malaysian ringgit' + }, + { + name: 'Maldives', + capital: 'Malé', + languages: ['Divehi'], + population: 344023, + flag: 'https://restcountries.eu/data/mdv.svg', + currency: 'Maldivian rufiyaa' + }, + { + name: 'Mali', + capital: 'Bamako', + languages: ['French'], + population: 18135000, + flag: 'https://restcountries.eu/data/mli.svg', + currency: 'West African CFA franc' + }, + { + name: 'Malta', + capital: 'Valletta', + languages: ['Maltese', 'English'], + population: 425384, + flag: 'https://restcountries.eu/data/mlt.svg', + currency: 'Euro' + }, + { + name: 'Marshall Islands', + capital: 'Majuro', + languages: ['English', 'Marshallese'], + population: 54880, + flag: 'https://restcountries.eu/data/mhl.svg', + currency: 'United States dollar' + }, + { + name: 'Martinique', + capital: 'Fort-de-France', + languages: ['French'], + population: 378243, + flag: 'https://restcountries.eu/data/mtq.svg', + currency: 'Euro' + }, + { + name: 'Mauritania', + capital: 'Nouakchott', + languages: ['Arabic'], + population: 3718678, + flag: 'https://restcountries.eu/data/mrt.svg', + currency: 'Mauritanian ouguiya' + }, + { + name: 'Mauritius', + capital: 'Port Louis', + languages: ['English'], + population: 1262879, + flag: 'https://restcountries.eu/data/mus.svg', + currency: 'Mauritian rupee' + }, + { + name: 'Mayotte', + capital: 'Mamoudzou', + languages: ['French'], + population: 226915, + flag: 'https://restcountries.eu/data/myt.svg', + currency: 'Euro' + }, + { + name: 'Mexico', + capital: 'Mexico City', + languages: ['Spanish'], + population: 122273473, + flag: 'https://restcountries.eu/data/mex.svg', + currency: 'Mexican peso' + }, + { + name: 'Micronesia (Federated States of)', + capital: 'Palikir', + languages: ['English'], + population: 102800, + flag: 'https://restcountries.eu/data/fsm.svg', + currency: '[D]' + }, + { + name: 'Moldova (Republic of)', + capital: 'Chișinău', + languages: ['Romanian'], + population: 3553100, + flag: 'https://restcountries.eu/data/mda.svg', + currency: 'Moldovan leu' + }, + { + name: 'Monaco', + capital: 'Monaco', + languages: ['French'], + population: 38400, + flag: 'https://restcountries.eu/data/mco.svg', + currency: 'Euro' + }, + { + name: 'Mongolia', + capital: 'Ulan Bator', + languages: ['Mongolian'], + population: 3093100, + flag: 'https://restcountries.eu/data/mng.svg', + currency: 'Mongolian tögrög' + }, + { + name: 'Montenegro', + capital: 'Podgorica', + languages: ['Serbian', 'Bosnian', 'Albanian', 'Croatian'], + population: 621810, + flag: 'https://restcountries.eu/data/mne.svg', + currency: 'Euro' + }, + { + name: 'Montserrat', + capital: 'Plymouth', + languages: ['English'], + population: 4922, + flag: 'https://restcountries.eu/data/msr.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Morocco', + capital: 'Rabat', + languages: ['Arabic'], + population: 33337529, + flag: 'https://restcountries.eu/data/mar.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Mozambique', + capital: 'Maputo', + languages: ['Portuguese'], + population: 26423700, + flag: 'https://restcountries.eu/data/moz.svg', + currency: 'Mozambican metical' + }, + { + name: 'Myanmar', + capital: 'Naypyidaw', + languages: ['Burmese'], + population: 51419420, + flag: 'https://restcountries.eu/data/mmr.svg', + currency: 'Burmese kyat' + }, + { + name: 'Namibia', + capital: 'Windhoek', + languages: ['English', 'Afrikaans'], + population: 2324388, + flag: 'https://restcountries.eu/data/nam.svg', + currency: 'Namibian dollar' + }, + { + name: 'Nauru', + capital: 'Yaren', + languages: ['English', 'Nauruan'], + population: 10084, + flag: 'https://restcountries.eu/data/nru.svg', + currency: 'Australian dollar' + }, + { + name: 'Nepal', + capital: 'Kathmandu', + languages: ['Nepali'], + population: 28431500, + flag: 'https://restcountries.eu/data/npl.svg', + currency: 'Nepalese rupee' + }, + { + name: 'Netherlands', + capital: 'Amsterdam', + languages: ['Dutch'], + population: 17019800, + flag: 'https://restcountries.eu/data/nld.svg', + currency: 'Euro' + }, + { + name: 'New Caledonia', + capital: 'Nouméa', + languages: ['French'], + population: 268767, + flag: 'https://restcountries.eu/data/ncl.svg', + currency: 'CFP franc' + }, + { + name: 'New Zealand', + capital: 'Wellington', + languages: ['English', 'Māori'], + population: 4697854, + flag: 'https://restcountries.eu/data/nzl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Nicaragua', + capital: 'Managua', + languages: ['Spanish'], + population: 6262703, + flag: 'https://restcountries.eu/data/nic.svg', + currency: 'Nicaraguan córdoba' + }, + { + name: 'Niger', + capital: 'Niamey', + languages: ['French'], + population: 20715000, + flag: 'https://restcountries.eu/data/ner.svg', + currency: 'West African CFA franc' + }, + { + name: 'Nigeria', + capital: 'Abuja', + languages: ['English'], + population: 186988000, + flag: 'https://restcountries.eu/data/nga.svg', + currency: 'Nigerian naira' + }, + { + name: 'Niue', + capital: 'Alofi', + languages: ['English'], + population: 1470, + flag: 'https://restcountries.eu/data/niu.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Norfolk Island', + capital: 'Kingston', + languages: ['English'], + population: 2302, + flag: 'https://restcountries.eu/data/nfk.svg', + currency: 'Australian dollar' + }, + { + name: "Korea (Democratic People's Republic of)", + capital: 'Pyongyang', + languages: ['Korean'], + population: 25281000, + flag: 'https://restcountries.eu/data/prk.svg', + currency: 'North Korean won' + }, + { + name: 'Northern Mariana Islands', + capital: 'Saipan', + languages: ['English', 'Chamorro'], + population: 56940, + flag: 'https://restcountries.eu/data/mnp.svg', + currency: 'United States dollar' + }, + { + name: 'Norway', + capital: 'Oslo', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 5223256, + flag: 'https://restcountries.eu/data/nor.svg', + currency: 'Norwegian krone' + }, + { + name: 'Oman', + capital: 'Muscat', + languages: ['Arabic'], + population: 4420133, + flag: 'https://restcountries.eu/data/omn.svg', + currency: 'Omani rial' + }, + { + name: 'Pakistan', + capital: 'Islamabad', + languages: ['English', 'Urdu'], + population: 194125062, + flag: 'https://restcountries.eu/data/pak.svg', + currency: 'Pakistani rupee' + }, + { + name: 'Palau', + capital: 'Ngerulmud', + languages: ['English'], + population: 17950, + flag: 'https://restcountries.eu/data/plw.svg', + currency: '[E]' + }, + { + name: 'Palestine, State of', + capital: 'Ramallah', + languages: ['Arabic'], + population: 4682467, + flag: 'https://restcountries.eu/data/pse.svg', + currency: 'Israeli new sheqel' + }, + { + name: 'Panama', + capital: 'Panama City', + languages: ['Spanish'], + population: 3814672, + flag: 'https://restcountries.eu/data/pan.svg', + currency: 'Panamanian balboa' + }, + { + name: 'Papua New Guinea', + capital: 'Port Moresby', + languages: ['English'], + population: 8083700, + flag: 'https://restcountries.eu/data/png.svg', + currency: 'Papua New Guinean kina' + }, + { + name: 'Paraguay', + capital: 'Asunción', + languages: ['Spanish', 'Guaraní'], + population: 6854536, + flag: 'https://restcountries.eu/data/pry.svg', + currency: 'Paraguayan guaraní' + }, + { + name: 'Peru', + capital: 'Lima', + languages: ['Spanish'], + population: 31488700, + flag: 'https://restcountries.eu/data/per.svg', + currency: 'Peruvian sol' + }, + { + name: 'Philippines', + capital: 'Manila', + languages: ['English'], + population: 103279800, + flag: 'https://restcountries.eu/data/phl.svg', + currency: 'Philippine peso' + }, + { + name: 'Pitcairn', + capital: 'Adamstown', + languages: ['English'], + population: 56, + flag: 'https://restcountries.eu/data/pcn.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Poland', + capital: 'Warsaw', + languages: ['Polish'], + population: 38437239, + flag: 'https://restcountries.eu/data/pol.svg', + currency: 'Polish złoty' + }, + { + name: 'Portugal', + capital: 'Lisbon', + languages: ['Portuguese'], + population: 10374822, + flag: 'https://restcountries.eu/data/prt.svg', + currency: 'Euro' + }, + { + name: 'Puerto Rico', + capital: 'San Juan', + languages: ['Spanish', 'English'], + population: 3474182, + flag: 'https://restcountries.eu/data/pri.svg', + currency: 'United States dollar' + }, + { + name: 'Qatar', + capital: 'Doha', + languages: ['Arabic'], + population: 2587564, + flag: 'https://restcountries.eu/data/qat.svg', + currency: 'Qatari riyal' + }, + { + name: 'Republic of Kosovo', + capital: 'Pristina', + languages: ['Albanian', 'Serbian'], + population: 1733842, + flag: 'https://restcountries.eu/data/kos.svg', + currency: 'Euro' + }, + { + name: 'Réunion', + capital: 'Saint-Denis', + languages: ['French'], + population: 840974, + flag: 'https://restcountries.eu/data/reu.svg', + currency: 'Euro' + }, + { + name: 'Romania', + capital: 'Bucharest', + languages: ['Romanian'], + population: 19861408, + flag: 'https://restcountries.eu/data/rou.svg', + currency: 'Romanian leu' + }, + { + name: 'Russian Federation', + capital: 'Moscow', + languages: ['Russian'], + population: 146599183, + flag: 'https://restcountries.eu/data/rus.svg', + currency: 'Russian ruble' + }, + { + name: 'Rwanda', + capital: 'Kigali', + languages: ['Kinyarwanda', 'English', 'French'], + population: 11553188, + flag: 'https://restcountries.eu/data/rwa.svg', + currency: 'Rwandan franc' + }, + { + name: 'Saint Barthélemy', + capital: 'Gustavia', + languages: ['French'], + population: 9417, + flag: 'https://restcountries.eu/data/blm.svg', + currency: 'Euro' + }, + { + name: 'Saint Helena, Ascension and Tristan da Cunha', + capital: 'Jamestown', + languages: ['English'], + population: 4255, + flag: 'https://restcountries.eu/data/shn.svg', + currency: 'Saint Helena pound' + }, + { + name: 'Saint Kitts and Nevis', + capital: 'Basseterre', + languages: ['English'], + population: 46204, + flag: 'https://restcountries.eu/data/kna.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Lucia', + capital: 'Castries', + languages: ['English'], + population: 186000, + flag: 'https://restcountries.eu/data/lca.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Martin (French part)', + capital: 'Marigot', + languages: ['English', 'French', 'Dutch'], + population: 36979, + flag: 'https://restcountries.eu/data/maf.svg', + currency: 'Euro' + }, + { + name: 'Saint Pierre and Miquelon', + capital: 'Saint-Pierre', + languages: ['French'], + population: 6069, + flag: 'https://restcountries.eu/data/spm.svg', + currency: 'Euro' + }, + { + name: 'Saint Vincent and the Grenadines', + capital: 'Kingstown', + languages: ['English'], + population: 109991, + flag: 'https://restcountries.eu/data/vct.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Samoa', + capital: 'Apia', + languages: ['Samoan', 'English'], + population: 194899, + flag: 'https://restcountries.eu/data/wsm.svg', + currency: 'Samoan tālā' + }, + { + name: 'San Marino', + capital: 'City of San Marino', + languages: ['Italian'], + population: 33005, + flag: 'https://restcountries.eu/data/smr.svg', + currency: 'Euro' + }, + { + name: 'Sao Tome and Principe', + capital: 'São Tomé', + languages: ['Portuguese'], + population: 187356, + flag: 'https://restcountries.eu/data/stp.svg', + currency: 'São Tomé and Príncipe dobra' + }, + { + name: 'Saudi Arabia', + capital: 'Riyadh', + languages: ['Arabic'], + population: 32248200, + flag: 'https://restcountries.eu/data/sau.svg', + currency: 'Saudi riyal' + }, + { + name: 'Senegal', + capital: 'Dakar', + languages: ['French'], + population: 14799859, + flag: 'https://restcountries.eu/data/sen.svg', + currency: 'West African CFA franc' + }, + { + name: 'Serbia', + capital: 'Belgrade', + languages: ['Serbian'], + population: 7076372, + flag: 'https://restcountries.eu/data/srb.svg', + currency: 'Serbian dinar' + }, + { + name: 'Seychelles', + capital: 'Victoria', + languages: ['French', 'English'], + population: 91400, + flag: 'https://restcountries.eu/data/syc.svg', + currency: 'Seychellois rupee' + }, + { + name: 'Sierra Leone', + capital: 'Freetown', + languages: ['English'], + population: 7075641, + flag: 'https://restcountries.eu/data/sle.svg', + currency: 'Sierra Leonean leone' + }, + { + name: 'Singapore', + capital: 'Singapore', + languages: ['English', 'Malay', 'Tamil', 'Chinese'], + population: 5535000, + flag: 'https://restcountries.eu/data/sgp.svg', + currency: 'Brunei dollar' + }, + { + name: 'Sint Maarten (Dutch part)', + capital: 'Philipsburg', + languages: ['Dutch', 'English'], + population: 38247, + flag: 'https://restcountries.eu/data/sxm.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Slovakia', + capital: 'Bratislava', + languages: ['Slovak'], + population: 5426252, + flag: 'https://restcountries.eu/data/svk.svg', + currency: 'Euro' + }, + { + name: 'Slovenia', + capital: 'Ljubljana', + languages: ['Slovene'], + population: 2064188, + flag: 'https://restcountries.eu/data/svn.svg', + currency: 'Euro' + }, + { + name: 'Solomon Islands', + capital: 'Honiara', + languages: ['English'], + population: 642000, + flag: 'https://restcountries.eu/data/slb.svg', + currency: 'Solomon Islands dollar' + }, + { + name: 'Somalia', + capital: 'Mogadishu', + languages: ['Somali', 'Arabic'], + population: 11079000, + flag: 'https://restcountries.eu/data/som.svg', + currency: 'Somali shilling' + }, + { + name: 'South Africa', + capital: 'Pretoria', + languages: [ + 'Afrikaans', + 'English', + 'Southern Ndebele', + 'Southern Sotho', + 'Swati', + 'Tswana', + 'Tsonga', + 'Venda', + 'Xhosa', + 'Zulu' + ], + population: 55653654, + flag: 'https://restcountries.eu/data/zaf.svg', + currency: 'South African rand' + }, + { + name: 'South Georgia and the South Sandwich Islands', + capital: 'King Edward Point', + languages: ['English'], + population: 30, + flag: 'https://restcountries.eu/data/sgs.svg', + currency: 'British pound' + }, + { + name: 'Korea (Republic of)', + capital: 'Seoul', + languages: ['Korean'], + population: 50801405, + flag: 'https://restcountries.eu/data/kor.svg', + currency: 'South Korean won' + }, + { + name: 'South Sudan', + capital: 'Juba', + languages: ['English'], + population: 12131000, + flag: 'https://restcountries.eu/data/ssd.svg', + currency: 'South Sudanese pound' + }, + { + name: 'Spain', + capital: 'Madrid', + languages: ['Spanish'], + population: 46438422, + flag: 'https://restcountries.eu/data/esp.svg', + currency: 'Euro' + }, + { + name: 'Sri Lanka', + capital: 'Colombo', + languages: ['Sinhalese', 'Tamil'], + population: 20966000, + flag: 'https://restcountries.eu/data/lka.svg', + currency: 'Sri Lankan rupee' + }, + { + name: 'Sudan', + capital: 'Khartoum', + languages: ['Arabic', 'English'], + population: 39598700, + flag: 'https://restcountries.eu/data/sdn.svg', + currency: 'Sudanese pound' + }, + { + name: 'Suriname', + capital: 'Paramaribo', + languages: ['Dutch'], + population: 541638, + flag: 'https://restcountries.eu/data/sur.svg', + currency: 'Surinamese dollar' + }, + { + name: 'Svalbard and Jan Mayen', + capital: 'Longyearbyen', + languages: ['Norwegian'], + population: 2562, + flag: 'https://restcountries.eu/data/sjm.svg', + currency: 'Norwegian krone' + }, + { + name: 'Swaziland', + capital: 'Lobamba', + languages: ['English', 'Swati'], + population: 1132657, + flag: 'https://restcountries.eu/data/swz.svg', + currency: 'Swazi lilangeni' + }, + { + name: 'Sweden', + capital: 'Stockholm', + languages: ['Swedish'], + population: 9894888, + flag: 'https://restcountries.eu/data/swe.svg', + currency: 'Swedish krona' + }, + { + name: 'Switzerland', + capital: 'Bern', + languages: ['German', 'French', 'Italian'], + population: 8341600, + flag: 'https://restcountries.eu/data/che.svg', + currency: 'Swiss franc' + }, + { + name: 'Syrian Arab Republic', + capital: 'Damascus', + languages: ['Arabic'], + population: 18564000, + flag: 'https://restcountries.eu/data/syr.svg', + currency: 'Syrian pound' + }, + { + name: 'Taiwan', + capital: 'Taipei', + languages: ['Chinese'], + population: 23503349, + flag: 'https://restcountries.eu/data/twn.svg', + currency: 'New Taiwan dollar' + }, + { + name: 'Tajikistan', + capital: 'Dushanbe', + languages: ['Tajik', 'Russian'], + population: 8593600, + flag: 'https://restcountries.eu/data/tjk.svg', + currency: 'Tajikistani somoni' + }, + { + name: 'Tanzania, United Republic of', + capital: 'Dodoma', + languages: ['Swahili', 'English'], + population: 55155000, + flag: 'https://restcountries.eu/data/tza.svg', + currency: 'Tanzanian shilling' + }, + { + name: 'Thailand', + capital: 'Bangkok', + languages: ['Thai'], + population: 65327652, + flag: 'https://restcountries.eu/data/tha.svg', + currency: 'Thai baht' + }, + { + name: 'Timor-Leste', + capital: 'Dili', + languages: ['Portuguese'], + population: 1167242, + flag: 'https://restcountries.eu/data/tls.svg', + currency: 'United States dollar' + }, + { + name: 'Togo', + capital: 'Lomé', + languages: ['French'], + population: 7143000, + flag: 'https://restcountries.eu/data/tgo.svg', + currency: 'West African CFA franc' + }, + { + name: 'Tokelau', + capital: 'Fakaofo', + languages: ['English'], + population: 1411, + flag: 'https://restcountries.eu/data/tkl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Tonga', + capital: "Nuku'alofa", + languages: ['English', 'Tonga (Tonga Islands)'], + population: 103252, + flag: 'https://restcountries.eu/data/ton.svg', + currency: 'Tongan paʻanga' + }, + { + name: 'Trinidad and Tobago', + capital: 'Port of Spain', + languages: ['English'], + population: 1349667, + flag: 'https://restcountries.eu/data/tto.svg', + currency: 'Trinidad and Tobago dollar' + }, + { + name: 'Tunisia', + capital: 'Tunis', + languages: ['Arabic'], + population: 11154400, + flag: 'https://restcountries.eu/data/tun.svg', + currency: 'Tunisian dinar' + }, + { + name: 'Turkey', + capital: 'Ankara', + languages: ['Turkish'], + population: 78741053, + flag: 'https://restcountries.eu/data/tur.svg', + currency: 'Turkish lira' + }, + { + name: 'Turkmenistan', + capital: 'Ashgabat', + languages: ['Turkmen', 'Russian'], + population: 4751120, + flag: 'https://restcountries.eu/data/tkm.svg', + currency: 'Turkmenistan manat' + }, + { + name: 'Turks and Caicos Islands', + capital: 'Cockburn Town', + languages: ['English'], + population: 31458, + flag: 'https://restcountries.eu/data/tca.svg', + currency: 'United States dollar' + }, + { + name: 'Tuvalu', + capital: 'Funafuti', + languages: ['English'], + population: 10640, + flag: 'https://restcountries.eu/data/tuv.svg', + currency: 'Australian dollar' + }, + { + name: 'Uganda', + capital: 'Kampala', + languages: ['English', 'Swahili'], + population: 33860700, + flag: 'https://restcountries.eu/data/uga.svg', + currency: 'Ugandan shilling' + }, + { + name: 'Ukraine', + capital: 'Kiev', + languages: ['Ukrainian'], + population: 42692393, + flag: 'https://restcountries.eu/data/ukr.svg', + currency: 'Ukrainian hryvnia' + }, + { + name: 'United Arab Emirates', + capital: 'Abu Dhabi', + languages: ['Arabic'], + population: 9856000, + flag: 'https://restcountries.eu/data/are.svg', + currency: 'United Arab Emirates dirham' + }, + { + name: 'United Kingdom of Great Britain and Northern Ireland', + capital: 'London', + languages: ['English'], + population: 65110000, + flag: 'https://restcountries.eu/data/gbr.svg', + currency: 'British pound' + }, + { + name: 'United States of America', + capital: 'Washington, D.C.', + languages: ['English'], + population: 323947000, + flag: 'https://restcountries.eu/data/usa.svg', + currency: 'United States dollar' + }, + { + name: 'Uruguay', + capital: 'Montevideo', + languages: ['Spanish'], + population: 3480222, + flag: 'https://restcountries.eu/data/ury.svg', + currency: 'Uruguayan peso' + }, + { + name: 'Uzbekistan', + capital: 'Tashkent', + languages: ['Uzbek', 'Russian'], + population: 31576400, + flag: 'https://restcountries.eu/data/uzb.svg', + currency: "Uzbekistani so'm" + }, + { + name: 'Vanuatu', + capital: 'Port Vila', + languages: ['Bislama', 'English', 'French'], + population: 277500, + flag: 'https://restcountries.eu/data/vut.svg', + currency: 'Vanuatu vatu' + }, + { + name: 'Venezuela (Bolivarian Republic of)', + capital: 'Caracas', + languages: ['Spanish'], + population: 31028700, + flag: 'https://restcountries.eu/data/ven.svg', + currency: 'Venezuelan bolívar' + }, + { + name: 'Viet Nam', + capital: 'Hanoi', + languages: ['Vietnamese'], + population: 92700000, + flag: 'https://restcountries.eu/data/vnm.svg', + currency: 'Vietnamese đồng' + }, + { + name: 'Wallis and Futuna', + capital: 'Mata-Utu', + languages: ['French'], + population: 11750, + flag: 'https://restcountries.eu/data/wlf.svg', + currency: 'CFP franc' + }, + { + name: 'Western Sahara', + capital: 'El Aaiún', + languages: ['Spanish'], + population: 510713, + flag: 'https://restcountries.eu/data/esh.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Yemen', + capital: "Sana'a", + languages: ['Arabic'], + population: 27478000, + flag: 'https://restcountries.eu/data/yem.svg', + currency: 'Yemeni rial' + }, + { + name: 'Zambia', + capital: 'Lusaka', + languages: ['English'], + population: 15933883, + flag: 'https://restcountries.eu/data/zmb.svg', + currency: 'Zambian kwacha' + }, + { + name: 'Zimbabwe', + capital: 'Harare', + languages: ['English', 'Shona', 'Northern Ndebele'], + population: 14240168, + flag: 'https://restcountries.eu/data/zwe.svg', + currency: 'Botswana pula' + } +] diff --git a/14_Day_Error_handling/14_day_starter/index.html b/14_Day_Error_handling/14_day_starter/index.html new file mode 100644 index 0000000..b5aa290 --- /dev/null +++ b/14_Day_Error_handling/14_day_starter/index.html @@ -0,0 +1,17 @@ + + + + + 30DaysOfJavaScript:12 Day + + + +

30DaysOfJavaScript:14 Day

+

DOM

+ + + + + + + \ No newline at end of file diff --git a/14_Day_Error_handling/14_day_starter/scripts/main.js b/14_Day_Error_handling/14_day_starter/scripts/main.js new file mode 100644 index 0000000..c6045c8 --- /dev/null +++ b/14_Day_Error_handling/14_day_starter/scripts/main.js @@ -0,0 +1,2 @@ +console.log(countries) +alert('Open the console and check if the countries has been loaded') \ No newline at end of file diff --git a/15_Day_Classes/15_day_classes.md b/15_Day_Classes/15_day_classes.md new file mode 100644 index 0000000..7b46328 --- /dev/null +++ b/15_Day_Classes/15_day_classes.md @@ -0,0 +1,715 @@ +
+

30 Days Of JavaScript: Classes

+ + + + + Twitter Follow + + +Author: +Asabeneh Yetayeh
+ January, 2020 +
+ +
+ +[<< Day 14](../14_Day_Error_handling/14_day_error_handling.md) | [Day 16>>](../16_Day_JSON/16_day_json.md) + +![Thirty Days Of JavaScript](../images/banners/day_1_15.png) + +- [Day 15](#day-15) + - [Classes](#classes) + - [Defining a classes](#defining-a-classes) + - [Class Instantiation](#class-instantiation) + - [Class Constructor](#class-constructor) + - [Default values with constructor](#default-values-with-constructor) + - [Class methods](#class-methods) + - [Properties with initial value](#properties-with-initial-value) + - [getter](#getter) + - [setter](#setter) + - [Static method](#static-method) + - [Inheritance](#inheritance) + - [Overriding methods](#overriding-methods) + - [Exercises](#exercises) + - [Exercises Level 1](#exercises-level-1) + - [Exercises Level 2](#exercises-level-2) + - [Exercises Level 3](#exercises-level-3) + +# Day 15 + +## Classes + +JavaScript is an object oriented programming language. Everything in JavScript is an object, with its properties and methods. We create class to create an object. A Class is like an object constructor, or a "blueprint" for creating objects. We instantiate a class to create an object. The class defines attributes and the behavior of the object, while the object, on the other hand, represents the class. + +Once we create a class we can create object from it whenever we want. Creating an object from a class is called class instantiation. + +In the object section, we saw how to create an object literal. Object literal is a singleton. If we want to get a similar object , we have to write it. However, class allows to create many objects. This helps to reduce amount of code and repetition of code. + +### Defining a classes + +To define a class in JavaScript we need the keyword _class_ , the name of a class in **CamelCase** and block code(two curly brackets). Let us create a class name Person. + +```sh +// syntax +class ClassName { + // code goes here +} + +``` + +**Example:** + +```js +class Person { + // code goes here +} +``` + +We have created an Person class but it does not have any thing inside. + +### Class Instantiation + +Instantiation class means creating an object from a class. We need the keyword _new_ and we call the name of the class after the word new. + +Let us create a dog object from our Person class. + +```js +class Person { + // code goes here +} +const person = new Person() +console.log(person) +``` + +```sh +Person {} +``` + +As you can see, we have created a person object. Since the class did not have any properties yet the object is also empty. + +Let use the class constructor to pass different properties for the class. + +### Class Constructor + +The constructor is a builtin function which allows as to create a blueprint for our object. The constructor function starts with a keyword constructor followed by a parenthesis. Inside the parenthesis we pass the properties of the object as parameter. We use the _this_ keyword to attach the constructor parameters with the class. + +The following Person class constructor has firstName and lastName property. These properties are attached to the Person class using _this_ keyword. _This_ refers to the class itself. + +```js +class Person { + constructor(firstName, lastName) { + console.log(this) // Check the output from here + this.firstName = firstName + this.lastName = lastName + } +} + +const person = new Person() + +console.log(person) +``` + +```sh +Person {firstName: undefined, lastName} +``` + +All the keys of the object are undefined. When ever we instantiate we should pass the value of the properties. Let us pass value at this time when we instantiate the class. + +```js +class Person { + constructor(firstName, lastName) { + this.firstName = firstName + this.lastName = lastName + } +} + +const person1 = new Person('Asabeneh', 'Yetayeh') + +console.log(person1) +``` + +```sh +Person {firstName: "Asabeneh", lastName: "Yetayeh"} +``` + +As we have stated at the very beginning that once we create a class we can create many object using the class. Now, let us create many person objects using the Person class. + +```js +class Person { + constructor(firstName, lastName) { + console.log(this) // Check the output from here + this.firstName = firstName + this.lastName = lastName + } +} + +const person1 = new Person('Asabeneh', 'Yetayeh') +const person2 = new Person('Lidiya', 'Tekle') +const person3 = new Person('Abraham', 'Yetayeh') + +console.log(person1) +console.log(person2) +console.log(person3) +``` + +```sh +Person {firstName: "Asabeneh", lastName: "Yetayeh"} +Person {firstName: "Lidiya", lastName: "Tekle"} +Person {firstName: "Abraham", lastName: "Yetayeh"} +``` + +Using the class Person we created three persons object. As you can see our class did not many properties let us add more properties to the class. + +```js +class Person { + constructor(firstName, lastName, age, country, city) { + console.log(this) // Check the output from here + this.firstName = firstName + this.lastName = lastName + this.age = age + this.country = country + this.city = city + } +} + +const person1 = new Person('Asabeneh', 'Yetayeh', 250, 'Finland', 'Helsinki') + +console.log(person1) +``` + +```sh +Person {firstName: "Asabeneh", lastName: "Yetayeh", age: 250, country: "Finland", city: "Helsinki"} +``` + +### Default values with constructor + +The constructor function properties may have a default value like other regular functions. + +```js +class Person { + constructor( + firstName = 'Asabeneh', + lastName = 'Yetayeh', + age = 250, + country = 'Finland', + city = 'Helsinki' + ) { + this.firstName = firstName + this.lastName = lastName + this.age = age + this.country = country + this.city = city + } +} + +const person1 = new Person() // it will take the default values +const person2 = new Person('Lidiya', 'Tekle', 28, 'Finland', 'Espoo') + +console.log(person1) +console.log(person2) +``` + +```sh +Person {firstName: "Asabeneh", lastName: "Yetayeh", age: 250, country: "Finland", city: "Helsinki"} +Person {firstName: "Lidiya", lastName: "Tekle", age: 28, country: "Finland", city: "Espoo"} +``` + +### Class methods + +The constructor inside a class is a builtin function which allow us to create a blueprint for the object. In a class we can create class methods. Methods are JavaScript functions inside the class. Let us create some class methods. + +```js +class Person { + constructor(firstName, lastName, age, country, city) { + this.firstName = firstName + this.lastName = lastName + this.age = age + this.country = country + this.city = city + } + getFullName() { + const fullName = this.firstName + ' ' + this.lastName + return fullName + } +} + +const person1 = new Person('Asabeneh', 'Yetayeh', 250, 'Finland', 'Helsinki') +const person2 = new Person('Lidiya', 'Tekle', 28, 'Finland', 'Espoo') + +console.log(person1.getFullName()) +console.log(person2.getFullName()) +``` + +```sh +Asabeneh Yetayeh +test.js:19 Lidiya Tekle +``` + +### Properties with initial value + +When we create a class for some properties we may have an initial value. For instance if you are playing a game, you starting score will be zero. So, we may have a starting score or score which is zero. In other way, we may have an initial skill and we will acquire some skill after some time. + +```js +class Person { + constructor(firstName, lastName, age, country, city) { + this.firstName = firstName + this.lastName = lastName + this.age = age + this.country = country + this.city = city + this.score = 0 + this.skills = [] + } + getFullName() { + const fullName = this.firstName + ' ' + this.lastName + return fullName + } +} + +const person1 = new Person('Asabeneh', 'Yetayeh', 250, 'Finland', 'Helsinki') +const person2 = new Person('Lidiya', 'Tekle', 28, 'Finland', 'Espoo') + +console.log(person1.score) +console.log(person2.score) + +console.log(person1.skills) +console.log(person2.skills) +``` + +```sh +0 +0 +[] +[] +``` + +A method could be regular method or a getter or a setter. Let us see, getter and setter. + +### getter + +The get method allow us to access value from the object. We write a get method using keyword _get_ followed by a function. Instead of accessing properties directly from the object we use getter to get the value. See the example bellow + +```js +class Person { + constructor(firstName, lastName, age, country, city) { + this.firstName = firstName + this.lastName = lastName + this.age = age + this.country = country + this.city = city + this.score = 0 + this.skills = [] + } + getFullName() { + const fullName = this.firstName + ' ' + this.lastName + return fullName + } + get getscore() { + return this.score + } + get getSkills() { + return this.skills + } +} + +const person1 = new Person('Asabeneh', 'Yetayeh', 250, 'Finland', 'Helsinki') +const person2 = new Person('Lidiya', 'Tekle', 28, 'Finland', 'Espoo') + +console.log(person1.getScore) // We do not need parenthesis to call a getter method +console.log(person2.getScore) + +console.log(person1.getSkills) +console.log(person2.getSkills) +``` + +```sh +0 +0 +[] +[] +``` + +### setter + +The setter method allow us to modify the value of certain properties. We write a setter method using keyword _set_ followed by a function. See the example bellow. + +```js +class Person { + constructor(firstName, lastName, age, country, city) { + this.firstName = firstName + this.lastName = lastName + this.age = age + this.country = country + this.city = city + this.score = 0 + this.skills = [] + } + getFullName() { + const fullName = this.firstName + ' ' + this.lastName + return fullName + } + get getScore() { + return this.score + } + get getSkills() { + return this.skills + } + set setScore(score) { + this.score += score + } + set setSkill(skill) { + this.skills.push(skill) + } +} + +const person1 = new Person('Asabeneh', 'Yetayeh', 250, 'Finland', 'Helsinki') +const person2 = new Person('Lidiya', 'Tekle', 28, 'Finland', 'Espoo') + +person1.setScore = 1 +person1.setSkill = 'HTML' +person1.setSkill = 'CSS' +person1.setSkill = 'JavaScript' + +person2.setScore = 1 +person2.setSkill = 'Planning' +person2.setSkill = 'Managing' +person2.setSkill = 'Organizing' + +console.log(person1.score) +console.log(person2.score) + +console.log(person1.skills) +console.log(person2.skills) +``` + +```sh +1 +1 +["HTML", "CSS", "JavaScript"] +["Planning", "Managing", "Organizing"] +``` + +Do not be puzzled by the difference between regular method and a getter. If you know how to make a regular method you are good. Let us add regular method called getPersonInfo in the Person class. + +```js +class Person { + constructor(firstName, lastName, age, country, city) { + this.firstName = firstName + this.lastName = lastName + this.age = age + this.country = country + this.city = city + this.score = 0 + this.skills = [] + } + getFullName() { + const fullName = this.firstName + ' ' + this.lastName + return fullName + } + get getScore() { + return this.score + } + get getSkills() { + return this.skills + } + set setScore(score) { + this.score += score + } + set setSkill(skill) { + this.skills.push(skill) + } + getPersonInfo() { + let fullName = this.getFullName() + let skills = + this.skills.length > 0 && + this.skills.slice(0, this.skills.length - 1).join(', ') + + ` and ${this.skills[this.skills.length - 1]}` + let formattedSkills = skills ? `He knows ${skills}` : '' + + let info = `${fullName} is ${this.age}. He lives ${this.city}, ${this.country}. ${formattedSkills}` + return info + } +} + +const person1 = new Person('Asabeneh', 'Yetayeh', 250, 'Finland', 'Helsinki') +const person2 = new Person('Lidiya', 'Tekle', 28, 'Finland', 'Espoo') +const person3 = new Person('John', 'Doe', 50, 'Mars', 'Mars city') + +person1.setScore = 1 +person1.setSkill = 'HTML' +person1.setSkill = 'CSS' +person1.setSkill = 'JavaScript' + +person2.setScore = 1 +person2.setSkill = 'Planning' +person2.setSkill = 'Managing' +person2.setSkill = 'Organizing' + +console.log(person1.getScore) +console.log(person2.getScore) + +console.log(person1.getSkills) +console.log(person2.getSkills) +console.log(person3.getSkills) + +console.log(person1.getPersonInfo()) +console.log(person2.getPersonInfo()) +console.log(person3.getPersonInfo()) +``` + +```sh +1 +1 +["HTML", "CSS", "JavaScript"] +["Planning", "Managing", "Organizing"] +[] +Asabeneh Yetayeh is 250. He lives Helsinki, Finland. He knows HTML, CSS and JavaScript +Lidiya Tekle is 28. He lives Espoo, Finland. He knows Planning, Managing and Organizing +John Doe is 50. He lives Mars city, Mars. +``` + +### Static method + +The static keyword defines a static method for a class. Static methods are not called on instances of the class. Instead, they are called on the class itself. These are often utility functions, such as functions to create or clone objects. An example of static method is _Date.now()_. The _now_ method is called directly from the class. + +```js +class Person { + constructor(firstName, lastName, age, country, city) { + this.firstName = firstName + this.lastName = lastName + this.age = age + this.country = country + this.city = city + this.score = 0 + this.skills = [] + } + getFullName() { + const fullName = this.firstName + ' ' + this.lastName + return fullName + } + get getScore() { + return this.score + } + get getSkills() { + return this.skills + } + set setScore(score) { + this.score += score + } + set setSkill(skill) { + this.skills.push(skill) + } + getPersonInfo() { + let fullName = this.getFullName() + let skills = + this.skills.length > 0 && + this.skills.slice(0, this.skills.length - 1).join(', ') + + ` and ${this.skills[this.skills.length - 1]}` + + let formattedSkills = skills ? `He knows ${skills}` : '' + + let info = `${fullName} is ${this.age}. He lives ${this.city}, ${this.country}. ${formattedSkills}` + return info + } + static favoriteSkill() { + const skills = ['HTML', 'CSS', 'JS', 'React', 'Python', 'Node'] + const index = Math.floor(Math.random() * skills.length) + return skills[index] + } + static showDateTime() { + let now = new Date() + let year = now.getFullYear() + let month = now.getMonth() + 1 + let date = now.getDate() + let hours = now.getHours() + let minutes = now.getMinutes() + if (hours < 10) { + hours = '0' + hours + } + if (minutes < 10) { + minutes = '0' + minutes + } + + let dateMonthYear = date + '.' + month + '.' + year + let time = hours + ':' + minutes + let fullTime = dateMonthYear + ' ' + time + return fullTime + } +} + +console.log(Person.favoriteSkill()) +console.log(Person.showDateTime()) +``` + +```sh +Node +15.1.2020 23:56 +``` + +The static methods are methods which can be used as utility functions. + +## Inheritance + +Using inheritance we can access all the properties and the methods of the parent class. This reduces repetition of code. If you remember, we have a Person parent class and we will create children from it. Our children class could be student, teach etc. + +```js +// syntax +class ChildClassName extends { + // code goes here +} +``` + +Let us create a Student child class from Person parent class. + +```js +class Student extends Person { + saySomething() { + console.log('I am a child of the person class') + } +} + +const s1 = new Student('Asabeneh', 'Yetayeh', 'Finland', 250, 'Helsinki') +console.log(s1) +console.log(s1.saySomething()) +console.log(s1.getFullName()) +console.log(s1.getPersonInfo()) +``` + +```sh +Student {firstName: "Asabeneh", lastName: "Yetayeh", age: "Finland", country: 250, city: "Helsinki", …} +I am a child of the person class +Asabeneh Yetayeh +Student {firstName: "Asabeneh", lastName: "Yetayeh", age: "Finland", country: 250, city: "Helsinki", …} +Asabeneh Yetayeh is Finland. He lives Helsinki, 250. +``` + +### Overriding methods + +As you can see, we manage to access all the methods in the Person Class and we used it in the Student child class. We can customize the parent methods, we can add additional properties to a child class. If we want to customize, the methods and if we want to add extra properties, we need to use the constructor function the child class too. In side the constructor function we call the super() function to access all the properties from the parent class. The Person class didn't have gender but now let us give gender property for the child class, Student. If the same method name used in the child class, the parent method will be overridden. + +```js +class Student extends Person { + constructor(firstName, lastName, age, country, city, gender) { + super(firstName, lastName, age, country, city) + this.gender = gender + } + + saySomething() { + console.log('I am a child of the person class') + } + getPersonInfo() { + let fullName = this.getFullName() + let skills = + this.skills.length > 0 && + this.skills.slice(0, this.skills.length - 1).join(', ') + + ` and ${this.skills[this.skills.length - 1]}` + + let formattedSkills = skills ? `He knows ${skills}` : '' + let pronoun = this.gender == 'Male' ? 'He' : 'She' + + let info = `${fullName} is ${this.age}. ${pronoun} lives in ${this.city}, ${this.country}. ${formattedSkills}` + return info + } +} + +const s1 = new Student( + 'Asabeneh', + 'Yetayeh', + 250, + 'Finland', + 'Helsinki', + 'Male' +) +const s2 = new Student('Lidiya', 'Tekle', 28, 'Finland', 'Helsinki', 'Female') +s1.setScore = 1 +s1.setSkill = 'HTML' +s1.setSkill = 'CSS' +s1.setSkill = 'JavaScript' + +s2.setScore = 1 +s2.setSkill = 'Planning' +s2.setSkill = 'Managing' +s2.setSkill = 'Organizing' + +console.log(s1) + +console.log(s1.saySomething()) +console.log(s1.getFullName()) +console.log(s1.getPersonInfo()) + +console.log(s2.saySomething()) +console.log(s2.getFullName()) +console.log(s2.getPersonInfo()) +``` + +```sh +Student {firstName: "Asabeneh", lastName: "Yetayeh", age: 250, country: "Finland", city: "Helsinki", …} +Student {firstName: "Lidiya", lastName: "Tekle", age: 28, country: "Finland", city: "Helsinki", …} +I am a child of the person class +Asabeneh Yetayeh +Student {firstName: "Asabeneh", lastName: "Yetayeh", age: 250, country: "Finland", city: "Helsinki", …} +Asabeneh Yetayeh is 250. He lives in Helsinki, Finland. He knows HTML, CSS and JavaScript +I am a child of the person class +Lidiya Tekle +Student {firstName: "Lidiya", lastName: "Tekle", age: 28, country: "Finland", city: "Helsinki", …} +Lidiya Tekle is 28. She lives in Helsinki, Finland. He knows Planning, Managing and Organizing +``` + +Now, the getPersonInfo method has been overridden and it identifies if the person is male or female. + +🌕 You are excelling. Now, you knew class and you have the power to turn everything to an object. You made it to half way to your way to greatness. Now do some exercises for your brain and for your muscle. + +## Exercises + +### Exercises Level 1 + +1. Create an Animal class. The class will have name, age, color, legs properties and create different methods +2. Create a Dog and Cat child class from the Animal Class. + +### Exercises Level 2 + +1. Override the method you create in Animal class + +### Exercises Level 3 + +1. Let's try to develop a program which calculate measure of central tendency of a sample(mean, median, mode) and measure of variability(range, variance, standard deviation). In addition to those measures find the min, max, count, percentile, and frequency distribution of the sample. You can create a class called Statistics and create all the functions which do statistical calculations as method for the Statistics class. Check the output below. + +```JS +ages = [31, 26, 34, 37, 27, 26, 32, 32, 26, 27, 27, 24, 32, 33, 27, 25, 26, 38, 37, 31, 34, 24, 33, 29, 26] + +console.log('Count:', statistics.count()) // 25 +console.log('Sum: ', statistics.sum()) // 744 +console.log('Min: ', statistics.min()) // 24 +console.log('Max: ', statistics.max()) // 38 +console.log('Range: ', statistics.range() // 14 +console.log('Mean: ', statistics.mean()) // 30 +console.log('Median: ',statistics.median()) // 29 +console.log('Mode: ', statistics.mode()) // {'mode': 26, 'count': 5} +console.log('Variance: ',statistics.var()) // 17.5 +console.log('Standard Deviation: ', statistics.std()) // 4.2 +console.log('Variance: ',statistics.var()) // 17.5 +console.log('Frequency Distribution: ',statistics.freqDist()) // [(20.0, 26), (16.0, 27), (12.0, 32), (8.0, 37), (8.0, 34), (8.0, 33), (8.0, 31), (8.0, 24), (4.0, 38), (4.0, 29), (4.0, 25)] +``` + +```sh +// you output should look like this +console.log(statistics.describe()) +Count: 25 +Sum: 744 +Min: 24 +Max: 38 +Range: 14 +Mean: 30 +Median: 29 +Mode: (26, 5) +Variance: 17.5 +Standard Deviation: 4.2 +Frequency Distribution: [(20.0, 26), (16.0, 27), (12.0, 32), (8.0, 37), (8.0, 34), (8.0, 33), (8.0, 31), (8.0, 24), (4.0, 38), (4.0, 29), (4.0, 25)] +``` + +1. Create a class called PersonAccount. It has firstname, lastname, incomes, expenses properties and it has totalIncome, totalExpense, accountInfo,addIncome, addExpense and accountBalance methods. Incomes is a set of incomes and its description and expenses is also a set of expenses and its description. + +🎉 CONGRATULATIONS ! 🎉 + +[<< Day 14](../14_Day_Error_handling/14_day_error_handling.md) | [Day 16>>](../16_Day_JSON/16_day_json.md) diff --git a/15_Day_Classes/15_day_starter/data/countries_data.js b/15_Day_Classes/15_day_starter/data/countries_data.js new file mode 100644 index 0000000..92acddd --- /dev/null +++ b/15_Day_Classes/15_day_starter/data/countries_data.js @@ -0,0 +1,2013 @@ +const countries = [ + { + name: 'Afghanistan', + capital: 'Kabul', + languages: ['Pashto', 'Uzbek', 'Turkmen'], + population: 27657145, + flag: 'https://restcountries.eu/data/afg.svg', + currency: 'Afghan afghani' + }, + { + name: 'Åland Islands', + capital: 'Mariehamn', + languages: ['Swedish'], + population: 28875, + flag: 'https://restcountries.eu/data/ala.svg', + currency: 'Euro' + }, + { + name: 'Albania', + capital: 'Tirana', + languages: ['Albanian'], + population: 2886026, + flag: 'https://restcountries.eu/data/alb.svg', + currency: 'Albanian lek' + }, + { + name: 'Algeria', + capital: 'Algiers', + languages: ['Arabic'], + population: 40400000, + flag: 'https://restcountries.eu/data/dza.svg', + currency: 'Algerian dinar' + }, + { + name: 'American Samoa', + capital: 'Pago Pago', + languages: ['English', 'Samoan'], + population: 57100, + flag: 'https://restcountries.eu/data/asm.svg', + currency: 'United State Dollar' + }, + { + name: 'Andorra', + capital: 'Andorra la Vella', + languages: ['Catalan'], + population: 78014, + flag: 'https://restcountries.eu/data/and.svg', + currency: 'Euro' + }, + { + name: 'Angola', + capital: 'Luanda', + languages: ['Portuguese'], + population: 25868000, + flag: 'https://restcountries.eu/data/ago.svg', + currency: 'Angolan kwanza' + }, + { + name: 'Anguilla', + capital: 'The Valley', + languages: ['English'], + population: 13452, + flag: 'https://restcountries.eu/data/aia.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Antarctica', + capital: '', + languages: ['English', 'Russian'], + population: 1000, + flag: 'https://restcountries.eu/data/ata.svg', + currency: 'Australian dollar' + }, + { + name: 'Antigua and Barbuda', + capital: "Saint John's", + languages: ['English'], + population: 86295, + flag: 'https://restcountries.eu/data/atg.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Argentina', + capital: 'Buenos Aires', + languages: ['Spanish', 'Guaraní'], + population: 43590400, + flag: 'https://restcountries.eu/data/arg.svg', + currency: 'Argentine peso' + }, + { + name: 'Armenia', + capital: 'Yerevan', + languages: ['Armenian', 'Russian'], + population: 2994400, + flag: 'https://restcountries.eu/data/arm.svg', + currency: 'Armenian dram' + }, + { + name: 'Aruba', + capital: 'Oranjestad', + languages: ['Dutch', '(Eastern) Punjabi'], + population: 107394, + flag: 'https://restcountries.eu/data/abw.svg', + currency: 'Aruban florin' + }, + { + name: 'Australia', + capital: 'Canberra', + languages: ['English'], + population: 24117360, + flag: 'https://restcountries.eu/data/aus.svg', + currency: 'Australian dollar' + }, + { + name: 'Austria', + capital: 'Vienna', + languages: ['German'], + population: 8725931, + flag: 'https://restcountries.eu/data/aut.svg', + currency: 'Euro' + }, + { + name: 'Azerbaijan', + capital: 'Baku', + languages: ['Azerbaijani'], + population: 9730500, + flag: 'https://restcountries.eu/data/aze.svg', + currency: 'Azerbaijani manat' + }, + { + name: 'Bahamas', + capital: 'Nassau', + languages: ['English'], + population: 378040, + flag: 'https://restcountries.eu/data/bhs.svg', + currency: 'Bahamian dollar' + }, + { + name: 'Bahrain', + capital: 'Manama', + languages: ['Arabic'], + population: 1404900, + flag: 'https://restcountries.eu/data/bhr.svg', + currency: 'Bahraini dinar' + }, + { + name: 'Bangladesh', + capital: 'Dhaka', + languages: ['Bengali'], + population: 161006790, + flag: 'https://restcountries.eu/data/bgd.svg', + currency: 'Bangladeshi taka' + }, + { + name: 'Barbados', + capital: 'Bridgetown', + languages: ['English'], + population: 285000, + flag: 'https://restcountries.eu/data/brb.svg', + currency: 'Barbadian dollar' + }, + { + name: 'Belarus', + capital: 'Minsk', + languages: ['Belarusian', 'Russian'], + population: 9498700, + flag: 'https://restcountries.eu/data/blr.svg', + currency: 'New Belarusian ruble' + }, + { + name: 'Belgium', + capital: 'Brussels', + languages: ['Dutch', 'French', 'German'], + population: 11319511, + flag: 'https://restcountries.eu/data/bel.svg', + currency: 'Euro' + }, + { + name: 'Belize', + capital: 'Belmopan', + languages: ['English', 'Spanish'], + population: 370300, + flag: 'https://restcountries.eu/data/blz.svg', + currency: 'Belize dollar' + }, + { + name: 'Benin', + capital: 'Porto-Novo', + languages: ['French'], + population: 10653654, + flag: 'https://restcountries.eu/data/ben.svg', + currency: 'West African CFA franc' + }, + { + name: 'Bermuda', + capital: 'Hamilton', + languages: ['English'], + population: 61954, + flag: 'https://restcountries.eu/data/bmu.svg', + currency: 'Bermudian dollar' + }, + { + name: 'Bhutan', + capital: 'Thimphu', + languages: ['Dzongkha'], + population: 775620, + flag: 'https://restcountries.eu/data/btn.svg', + currency: 'Bhutanese ngultrum' + }, + { + name: 'Bolivia (Plurinational State of)', + capital: 'Sucre', + languages: ['Spanish', 'Aymara', 'Quechua'], + population: 10985059, + flag: 'https://restcountries.eu/data/bol.svg', + currency: 'Bolivian boliviano' + }, + { + name: 'Bonaire, Sint Eustatius and Saba', + capital: 'Kralendijk', + languages: ['Dutch'], + population: 17408, + flag: 'https://restcountries.eu/data/bes.svg', + currency: 'United States dollar' + }, + { + name: 'Bosnia and Herzegovina', + capital: 'Sarajevo', + languages: ['Bosnian', 'Croatian', 'Serbian'], + population: 3531159, + flag: 'https://restcountries.eu/data/bih.svg', + currency: 'Bosnia and Herzegovina convertible mark' + }, + { + name: 'Botswana', + capital: 'Gaborone', + languages: ['English', 'Tswana'], + population: 2141206, + flag: 'https://restcountries.eu/data/bwa.svg', + currency: 'Botswana pula' + }, + { + name: 'Bouvet Island', + capital: '', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 0, + flag: 'https://restcountries.eu/data/bvt.svg', + currency: 'Norwegian krone' + }, + { + name: 'Brazil', + capital: 'Brasília', + languages: ['Portuguese'], + population: 206135893, + flag: 'https://restcountries.eu/data/bra.svg', + currency: 'Brazilian real' + }, + { + name: 'British Indian Ocean Territory', + capital: 'Diego Garcia', + languages: ['English'], + population: 3000, + flag: 'https://restcountries.eu/data/iot.svg', + currency: 'United States dollar' + }, + { + name: 'United States Minor Outlying Islands', + capital: '', + languages: ['English'], + population: 300, + flag: 'https://restcountries.eu/data/umi.svg', + currency: 'United States Dollar' + }, + { + name: 'Virgin Islands (British)', + capital: 'Road Town', + languages: ['English'], + population: 28514, + flag: 'https://restcountries.eu/data/vgb.svg', + currency: '[D]' + }, + { + name: 'Virgin Islands (U.S.)', + capital: 'Charlotte Amalie', + languages: ['English'], + population: 114743, + flag: 'https://restcountries.eu/data/vir.svg', + currency: 'United States dollar' + }, + { + name: 'Brunei Darussalam', + capital: 'Bandar Seri Begawan', + languages: ['Malay'], + population: 411900, + flag: 'https://restcountries.eu/data/brn.svg', + currency: 'Brunei dollar' + }, + { + name: 'Bulgaria', + capital: 'Sofia', + languages: ['Bulgarian'], + population: 7153784, + flag: 'https://restcountries.eu/data/bgr.svg', + currency: 'Bulgarian lev' + }, + { + name: 'Burkina Faso', + capital: 'Ouagadougou', + languages: ['French', 'Fula'], + population: 19034397, + flag: 'https://restcountries.eu/data/bfa.svg', + currency: 'West African CFA franc' + }, + { + name: 'Burundi', + capital: 'Bujumbura', + languages: ['French', 'Kirundi'], + population: 10114505, + flag: 'https://restcountries.eu/data/bdi.svg', + currency: 'Burundian franc' + }, + { + name: 'Cambodia', + capital: 'Phnom Penh', + languages: ['Khmer'], + population: 15626444, + flag: 'https://restcountries.eu/data/khm.svg', + currency: 'Cambodian riel' + }, + { + name: 'Cameroon', + capital: 'Yaoundé', + languages: ['English', 'French'], + population: 22709892, + flag: 'https://restcountries.eu/data/cmr.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Canada', + capital: 'Ottawa', + languages: ['English', 'French'], + population: 36155487, + flag: 'https://restcountries.eu/data/can.svg', + currency: 'Canadian dollar' + }, + { + name: 'Cabo Verde', + capital: 'Praia', + languages: ['Portuguese'], + population: 531239, + flag: 'https://restcountries.eu/data/cpv.svg', + currency: 'Cape Verdean escudo' + }, + { + name: 'Cayman Islands', + capital: 'George Town', + languages: ['English'], + population: 58238, + flag: 'https://restcountries.eu/data/cym.svg', + currency: 'Cayman Islands dollar' + }, + { + name: 'Central African Republic', + capital: 'Bangui', + languages: ['French', 'Sango'], + population: 4998000, + flag: 'https://restcountries.eu/data/caf.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chad', + capital: "N'Djamena", + languages: ['French', 'Arabic'], + population: 14497000, + flag: 'https://restcountries.eu/data/tcd.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chile', + capital: 'Santiago', + languages: ['Spanish'], + population: 18191900, + flag: 'https://restcountries.eu/data/chl.svg', + currency: 'Chilean peso' + }, + { + name: 'China', + capital: 'Beijing', + languages: ['Chinese'], + population: 1377422166, + flag: 'https://restcountries.eu/data/chn.svg', + currency: 'Chinese yuan' + }, + { + name: 'Christmas Island', + capital: 'Flying Fish Cove', + languages: ['English'], + population: 2072, + flag: 'https://restcountries.eu/data/cxr.svg', + currency: 'Australian dollar' + }, + { + name: 'Cocos (Keeling) Islands', + capital: 'West Island', + languages: ['English'], + population: 550, + flag: 'https://restcountries.eu/data/cck.svg', + currency: 'Australian dollar' + }, + { + name: 'Colombia', + capital: 'Bogotá', + languages: ['Spanish'], + population: 48759958, + flag: 'https://restcountries.eu/data/col.svg', + currency: 'Colombian peso' + }, + { + name: 'Comoros', + capital: 'Moroni', + languages: ['Arabic', 'French'], + population: 806153, + flag: 'https://restcountries.eu/data/com.svg', + currency: 'Comorian franc' + }, + { + name: 'Congo', + capital: 'Brazzaville', + languages: ['French', 'Lingala'], + population: 4741000, + flag: 'https://restcountries.eu/data/cog.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Congo (Democratic Republic of the)', + capital: 'Kinshasa', + languages: ['French', 'Lingala', 'Kongo', 'Swahili', 'Luba-Katanga'], + population: 85026000, + flag: 'https://restcountries.eu/data/cod.svg', + currency: 'Congolese franc' + }, + { + name: 'Cook Islands', + capital: 'Avarua', + languages: ['English'], + population: 18100, + flag: 'https://restcountries.eu/data/cok.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Costa Rica', + capital: 'San José', + languages: ['Spanish'], + population: 4890379, + flag: 'https://restcountries.eu/data/cri.svg', + currency: 'Costa Rican colón' + }, + { + name: 'Croatia', + capital: 'Zagreb', + languages: ['Croatian'], + population: 4190669, + flag: 'https://restcountries.eu/data/hrv.svg', + currency: 'Croatian kuna' + }, + { + name: 'Cuba', + capital: 'Havana', + languages: ['Spanish'], + population: 11239004, + flag: 'https://restcountries.eu/data/cub.svg', + currency: 'Cuban convertible peso' + }, + { + name: 'Curaçao', + capital: 'Willemstad', + languages: ['Dutch', '(Eastern) Punjabi', 'English'], + population: 154843, + flag: 'https://restcountries.eu/data/cuw.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Cyprus', + capital: 'Nicosia', + languages: ['Greek (modern)', 'Turkish', 'Armenian'], + population: 847000, + flag: 'https://restcountries.eu/data/cyp.svg', + currency: 'Euro' + }, + { + name: 'Czech Republic', + capital: 'Prague', + languages: ['Czech', 'Slovak'], + population: 10558524, + flag: 'https://restcountries.eu/data/cze.svg', + currency: 'Czech koruna' + }, + { + name: 'Denmark', + capital: 'Copenhagen', + languages: ['Danish'], + population: 5717014, + flag: 'https://restcountries.eu/data/dnk.svg', + currency: 'Danish krone' + }, + { + name: 'Djibouti', + capital: 'Djibouti', + languages: ['French', 'Arabic'], + population: 900000, + flag: 'https://restcountries.eu/data/dji.svg', + currency: 'Djiboutian franc' + }, + { + name: 'Dominica', + capital: 'Roseau', + languages: ['English'], + population: 71293, + flag: 'https://restcountries.eu/data/dma.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Dominican Republic', + capital: 'Santo Domingo', + languages: ['Spanish'], + population: 10075045, + flag: 'https://restcountries.eu/data/dom.svg', + currency: 'Dominican peso' + }, + { + name: 'Ecuador', + capital: 'Quito', + languages: ['Spanish'], + population: 16545799, + flag: 'https://restcountries.eu/data/ecu.svg', + currency: 'United States dollar' + }, + { + name: 'Egypt', + capital: 'Cairo', + languages: ['Arabic'], + population: 91290000, + flag: 'https://restcountries.eu/data/egy.svg', + currency: 'Egyptian pound' + }, + { + name: 'El Salvador', + capital: 'San Salvador', + languages: ['Spanish'], + population: 6520675, + flag: 'https://restcountries.eu/data/slv.svg', + currency: 'United States dollar' + }, + { + name: 'Equatorial Guinea', + capital: 'Malabo', + languages: ['Spanish', 'French'], + population: 1222442, + flag: 'https://restcountries.eu/data/gnq.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Eritrea', + capital: 'Asmara', + languages: ['Tigrinya', 'Arabic', 'English'], + population: 5352000, + flag: 'https://restcountries.eu/data/eri.svg', + currency: 'Eritrean nakfa' + }, + { + name: 'Estonia', + capital: 'Tallinn', + languages: ['Estonian'], + population: 1315944, + flag: 'https://restcountries.eu/data/est.svg', + currency: 'Euro' + }, + { + name: 'Ethiopia', + capital: 'Addis Ababa', + languages: ['Amharic'], + population: 92206005, + flag: 'https://restcountries.eu/data/eth.svg', + currency: 'Ethiopian birr' + }, + { + name: 'Falkland Islands (Malvinas)', + capital: 'Stanley', + languages: ['English'], + population: 2563, + flag: 'https://restcountries.eu/data/flk.svg', + currency: 'Falkland Islands pound' + }, + { + name: 'Faroe Islands', + capital: 'Tórshavn', + languages: ['Faroese'], + population: 49376, + flag: 'https://restcountries.eu/data/fro.svg', + currency: 'Danish krone' + }, + { + name: 'Fiji', + capital: 'Suva', + languages: ['English', 'Fijian', 'Hindi', 'Urdu'], + population: 867000, + flag: 'https://restcountries.eu/data/fji.svg', + currency: 'Fijian dollar' + }, + { + name: 'Finland', + capital: 'Helsinki', + languages: ['Finnish', 'Swedish'], + population: 5491817, + flag: 'https://restcountries.eu/data/fin.svg', + currency: 'Euro' + }, + { + name: 'France', + capital: 'Paris', + languages: ['French'], + population: 66710000, + flag: 'https://restcountries.eu/data/fra.svg', + currency: 'Euro' + }, + { + name: 'French Guiana', + capital: 'Cayenne', + languages: ['French'], + population: 254541, + flag: 'https://restcountries.eu/data/guf.svg', + currency: 'Euro' + }, + { + name: 'French Polynesia', + capital: 'Papeetē', + languages: ['French'], + population: 271800, + flag: 'https://restcountries.eu/data/pyf.svg', + currency: 'CFP franc' + }, + { + name: 'French Southern Territories', + capital: 'Port-aux-Français', + languages: ['French'], + population: 140, + flag: 'https://restcountries.eu/data/atf.svg', + currency: 'Euro' + }, + { + name: 'Gabon', + capital: 'Libreville', + languages: ['French'], + population: 1802278, + flag: 'https://restcountries.eu/data/gab.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Gambia', + capital: 'Banjul', + languages: ['English'], + population: 1882450, + flag: 'https://restcountries.eu/data/gmb.svg', + currency: 'Gambian dalasi' + }, + { + name: 'Georgia', + capital: 'Tbilisi', + languages: ['Georgian'], + population: 3720400, + flag: 'https://restcountries.eu/data/geo.svg', + currency: 'Georgian Lari' + }, + { + name: 'Germany', + capital: 'Berlin', + languages: ['German'], + population: 81770900, + flag: 'https://restcountries.eu/data/deu.svg', + currency: 'Euro' + }, + { + name: 'Ghana', + capital: 'Accra', + languages: ['English'], + population: 27670174, + flag: 'https://restcountries.eu/data/gha.svg', + currency: 'Ghanaian cedi' + }, + { + name: 'Gibraltar', + capital: 'Gibraltar', + languages: ['English'], + population: 33140, + flag: 'https://restcountries.eu/data/gib.svg', + currency: 'Gibraltar pound' + }, + { + name: 'Greece', + capital: 'Athens', + languages: ['Greek (modern)'], + population: 10858018, + flag: 'https://restcountries.eu/data/grc.svg', + currency: 'Euro' + }, + { + name: 'Greenland', + capital: 'Nuuk', + languages: ['Kalaallisut'], + population: 55847, + flag: 'https://restcountries.eu/data/grl.svg', + currency: 'Danish krone' + }, + { + name: 'Grenada', + capital: "St. George's", + languages: ['English'], + population: 103328, + flag: 'https://restcountries.eu/data/grd.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Guadeloupe', + capital: 'Basse-Terre', + languages: ['French'], + population: 400132, + flag: 'https://restcountries.eu/data/glp.svg', + currency: 'Euro' + }, + { + name: 'Guam', + capital: 'Hagåtña', + languages: ['English', 'Chamorro', 'Spanish'], + population: 184200, + flag: 'https://restcountries.eu/data/gum.svg', + currency: 'United States dollar' + }, + { + name: 'Guatemala', + capital: 'Guatemala City', + languages: ['Spanish'], + population: 16176133, + flag: 'https://restcountries.eu/data/gtm.svg', + currency: 'Guatemalan quetzal' + }, + { + name: 'Guernsey', + capital: 'St. Peter Port', + languages: ['English', 'French'], + population: 62999, + flag: 'https://restcountries.eu/data/ggy.svg', + currency: 'British pound' + }, + { + name: 'Guinea', + capital: 'Conakry', + languages: ['French', 'Fula'], + population: 12947000, + flag: 'https://restcountries.eu/data/gin.svg', + currency: 'Guinean franc' + }, + { + name: 'Guinea-Bissau', + capital: 'Bissau', + languages: ['Portuguese'], + population: 1547777, + flag: 'https://restcountries.eu/data/gnb.svg', + currency: 'West African CFA franc' + }, + { + name: 'Guyana', + capital: 'Georgetown', + languages: ['English'], + population: 746900, + flag: 'https://restcountries.eu/data/guy.svg', + currency: 'Guyanese dollar' + }, + { + name: 'Haiti', + capital: 'Port-au-Prince', + languages: ['French', 'Haitian'], + population: 11078033, + flag: 'https://restcountries.eu/data/hti.svg', + currency: 'Haitian gourde' + }, + { + name: 'Heard Island and McDonald Islands', + capital: '', + languages: ['English'], + population: 0, + flag: 'https://restcountries.eu/data/hmd.svg', + currency: 'Australian dollar' + }, + { + name: 'Holy See', + capital: 'Rome', + languages: ['Latin', 'Italian', 'French', 'German'], + population: 451, + flag: 'https://restcountries.eu/data/vat.svg', + currency: 'Euro' + }, + { + name: 'Honduras', + capital: 'Tegucigalpa', + languages: ['Spanish'], + population: 8576532, + flag: 'https://restcountries.eu/data/hnd.svg', + currency: 'Honduran lempira' + }, + { + name: 'Hong Kong', + capital: 'City of Victoria', + languages: ['English', 'Chinese'], + population: 7324300, + flag: 'https://restcountries.eu/data/hkg.svg', + currency: 'Hong Kong dollar' + }, + { + name: 'Hungary', + capital: 'Budapest', + languages: ['Hungarian'], + population: 9823000, + flag: 'https://restcountries.eu/data/hun.svg', + currency: 'Hungarian forint' + }, + { + name: 'Iceland', + capital: 'Reykjavík', + languages: ['Icelandic'], + population: 334300, + flag: 'https://restcountries.eu/data/isl.svg', + currency: 'Icelandic króna' + }, + { + name: 'India', + capital: 'New Delhi', + languages: ['Hindi', 'English'], + population: 1295210000, + flag: 'https://restcountries.eu/data/ind.svg', + currency: 'Indian rupee' + }, + { + name: 'Indonesia', + capital: 'Jakarta', + languages: ['Indonesian'], + population: 258705000, + flag: 'https://restcountries.eu/data/idn.svg', + currency: 'Indonesian rupiah' + }, + { + name: "Côte d'Ivoire", + capital: 'Yamoussoukro', + languages: ['French'], + population: 22671331, + flag: 'https://restcountries.eu/data/civ.svg', + currency: 'West African CFA franc' + }, + { + name: 'Iran (Islamic Republic of)', + capital: 'Tehran', + languages: ['Persian (Farsi)'], + population: 79369900, + flag: 'https://restcountries.eu/data/irn.svg', + currency: 'Iranian rial' + }, + { + name: 'Iraq', + capital: 'Baghdad', + languages: ['Arabic', 'Kurdish'], + population: 37883543, + flag: 'https://restcountries.eu/data/irq.svg', + currency: 'Iraqi dinar' + }, + { + name: 'Ireland', + capital: 'Dublin', + languages: ['Irish', 'English'], + population: 6378000, + flag: 'https://restcountries.eu/data/irl.svg', + currency: 'Euro' + }, + { + name: 'Isle of Man', + capital: 'Douglas', + languages: ['English', 'Manx'], + population: 84497, + flag: 'https://restcountries.eu/data/imn.svg', + currency: 'British pound' + }, + { + name: 'Israel', + capital: 'Jerusalem', + languages: ['Hebrew (modern)', 'Arabic'], + population: 8527400, + flag: 'https://restcountries.eu/data/isr.svg', + currency: 'Israeli new shekel' + }, + { + name: 'Italy', + capital: 'Rome', + languages: ['Italian'], + population: 60665551, + flag: 'https://restcountries.eu/data/ita.svg', + currency: 'Euro' + }, + { + name: 'Jamaica', + capital: 'Kingston', + languages: ['English'], + population: 2723246, + flag: 'https://restcountries.eu/data/jam.svg', + currency: 'Jamaican dollar' + }, + { + name: 'Japan', + capital: 'Tokyo', + languages: ['Japanese'], + population: 126960000, + flag: 'https://restcountries.eu/data/jpn.svg', + currency: 'Japanese yen' + }, + { + name: 'Jersey', + capital: 'Saint Helier', + languages: ['English', 'French'], + population: 100800, + flag: 'https://restcountries.eu/data/jey.svg', + currency: 'British pound' + }, + { + name: 'Jordan', + capital: 'Amman', + languages: ['Arabic'], + population: 9531712, + flag: 'https://restcountries.eu/data/jor.svg', + currency: 'Jordanian dinar' + }, + { + name: 'Kazakhstan', + capital: 'Astana', + languages: ['Kazakh', 'Russian'], + population: 17753200, + flag: 'https://restcountries.eu/data/kaz.svg', + currency: 'Kazakhstani tenge' + }, + { + name: 'Kenya', + capital: 'Nairobi', + languages: ['English', 'Swahili'], + population: 47251000, + flag: 'https://restcountries.eu/data/ken.svg', + currency: 'Kenyan shilling' + }, + { + name: 'Kiribati', + capital: 'South Tarawa', + languages: ['English'], + population: 113400, + flag: 'https://restcountries.eu/data/kir.svg', + currency: 'Australian dollar' + }, + { + name: 'Kuwait', + capital: 'Kuwait City', + languages: ['Arabic'], + population: 4183658, + flag: 'https://restcountries.eu/data/kwt.svg', + currency: 'Kuwaiti dinar' + }, + { + name: 'Kyrgyzstan', + capital: 'Bishkek', + languages: ['Kyrgyz', 'Russian'], + population: 6047800, + flag: 'https://restcountries.eu/data/kgz.svg', + currency: 'Kyrgyzstani som' + }, + { + name: "Lao People's Democratic Republic", + capital: 'Vientiane', + languages: ['Lao'], + population: 6492400, + flag: 'https://restcountries.eu/data/lao.svg', + currency: 'Lao kip' + }, + { + name: 'Latvia', + capital: 'Riga', + languages: ['Latvian'], + population: 1961600, + flag: 'https://restcountries.eu/data/lva.svg', + currency: 'Euro' + }, + { + name: 'Lebanon', + capital: 'Beirut', + languages: ['Arabic', 'French'], + population: 5988000, + flag: 'https://restcountries.eu/data/lbn.svg', + currency: 'Lebanese pound' + }, + { + name: 'Lesotho', + capital: 'Maseru', + languages: ['English', 'Southern Sotho'], + population: 1894194, + flag: 'https://restcountries.eu/data/lso.svg', + currency: 'Lesotho loti' + }, + { + name: 'Liberia', + capital: 'Monrovia', + languages: ['English'], + population: 4615000, + flag: 'https://restcountries.eu/data/lbr.svg', + currency: 'Liberian dollar' + }, + { + name: 'Libya', + capital: 'Tripoli', + languages: ['Arabic'], + population: 6385000, + flag: 'https://restcountries.eu/data/lby.svg', + currency: 'Libyan dinar' + }, + { + name: 'Liechtenstein', + capital: 'Vaduz', + languages: ['German'], + population: 37623, + flag: 'https://restcountries.eu/data/lie.svg', + currency: 'Swiss franc' + }, + { + name: 'Lithuania', + capital: 'Vilnius', + languages: ['Lithuanian'], + population: 2872294, + flag: 'https://restcountries.eu/data/ltu.svg', + currency: 'Euro' + }, + { + name: 'Luxembourg', + capital: 'Luxembourg', + languages: ['French', 'German', 'Luxembourgish'], + population: 576200, + flag: 'https://restcountries.eu/data/lux.svg', + currency: 'Euro' + }, + { + name: 'Macao', + capital: '', + languages: ['Chinese', 'Portuguese'], + population: 649100, + flag: 'https://restcountries.eu/data/mac.svg', + currency: 'Macanese pataca' + }, + { + name: 'Macedonia (the former Yugoslav Republic of)', + capital: 'Skopje', + languages: ['Macedonian'], + population: 2058539, + flag: 'https://restcountries.eu/data/mkd.svg', + currency: 'Macedonian denar' + }, + { + name: 'Madagascar', + capital: 'Antananarivo', + languages: ['French', 'Malagasy'], + population: 22434363, + flag: 'https://restcountries.eu/data/mdg.svg', + currency: 'Malagasy ariary' + }, + { + name: 'Malawi', + capital: 'Lilongwe', + languages: ['English', 'Chichewa'], + population: 16832910, + flag: 'https://restcountries.eu/data/mwi.svg', + currency: 'Malawian kwacha' + }, + { + name: 'Malaysia', + capital: 'Kuala Lumpur', + languages: ['Malaysian'], + population: 31405416, + flag: 'https://restcountries.eu/data/mys.svg', + currency: 'Malaysian ringgit' + }, + { + name: 'Maldives', + capital: 'Malé', + languages: ['Divehi'], + population: 344023, + flag: 'https://restcountries.eu/data/mdv.svg', + currency: 'Maldivian rufiyaa' + }, + { + name: 'Mali', + capital: 'Bamako', + languages: ['French'], + population: 18135000, + flag: 'https://restcountries.eu/data/mli.svg', + currency: 'West African CFA franc' + }, + { + name: 'Malta', + capital: 'Valletta', + languages: ['Maltese', 'English'], + population: 425384, + flag: 'https://restcountries.eu/data/mlt.svg', + currency: 'Euro' + }, + { + name: 'Marshall Islands', + capital: 'Majuro', + languages: ['English', 'Marshallese'], + population: 54880, + flag: 'https://restcountries.eu/data/mhl.svg', + currency: 'United States dollar' + }, + { + name: 'Martinique', + capital: 'Fort-de-France', + languages: ['French'], + population: 378243, + flag: 'https://restcountries.eu/data/mtq.svg', + currency: 'Euro' + }, + { + name: 'Mauritania', + capital: 'Nouakchott', + languages: ['Arabic'], + population: 3718678, + flag: 'https://restcountries.eu/data/mrt.svg', + currency: 'Mauritanian ouguiya' + }, + { + name: 'Mauritius', + capital: 'Port Louis', + languages: ['English'], + population: 1262879, + flag: 'https://restcountries.eu/data/mus.svg', + currency: 'Mauritian rupee' + }, + { + name: 'Mayotte', + capital: 'Mamoudzou', + languages: ['French'], + population: 226915, + flag: 'https://restcountries.eu/data/myt.svg', + currency: 'Euro' + }, + { + name: 'Mexico', + capital: 'Mexico City', + languages: ['Spanish'], + population: 122273473, + flag: 'https://restcountries.eu/data/mex.svg', + currency: 'Mexican peso' + }, + { + name: 'Micronesia (Federated States of)', + capital: 'Palikir', + languages: ['English'], + population: 102800, + flag: 'https://restcountries.eu/data/fsm.svg', + currency: '[D]' + }, + { + name: 'Moldova (Republic of)', + capital: 'Chișinău', + languages: ['Romanian'], + population: 3553100, + flag: 'https://restcountries.eu/data/mda.svg', + currency: 'Moldovan leu' + }, + { + name: 'Monaco', + capital: 'Monaco', + languages: ['French'], + population: 38400, + flag: 'https://restcountries.eu/data/mco.svg', + currency: 'Euro' + }, + { + name: 'Mongolia', + capital: 'Ulan Bator', + languages: ['Mongolian'], + population: 3093100, + flag: 'https://restcountries.eu/data/mng.svg', + currency: 'Mongolian tögrög' + }, + { + name: 'Montenegro', + capital: 'Podgorica', + languages: ['Serbian', 'Bosnian', 'Albanian', 'Croatian'], + population: 621810, + flag: 'https://restcountries.eu/data/mne.svg', + currency: 'Euro' + }, + { + name: 'Montserrat', + capital: 'Plymouth', + languages: ['English'], + population: 4922, + flag: 'https://restcountries.eu/data/msr.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Morocco', + capital: 'Rabat', + languages: ['Arabic'], + population: 33337529, + flag: 'https://restcountries.eu/data/mar.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Mozambique', + capital: 'Maputo', + languages: ['Portuguese'], + population: 26423700, + flag: 'https://restcountries.eu/data/moz.svg', + currency: 'Mozambican metical' + }, + { + name: 'Myanmar', + capital: 'Naypyidaw', + languages: ['Burmese'], + population: 51419420, + flag: 'https://restcountries.eu/data/mmr.svg', + currency: 'Burmese kyat' + }, + { + name: 'Namibia', + capital: 'Windhoek', + languages: ['English', 'Afrikaans'], + population: 2324388, + flag: 'https://restcountries.eu/data/nam.svg', + currency: 'Namibian dollar' + }, + { + name: 'Nauru', + capital: 'Yaren', + languages: ['English', 'Nauruan'], + population: 10084, + flag: 'https://restcountries.eu/data/nru.svg', + currency: 'Australian dollar' + }, + { + name: 'Nepal', + capital: 'Kathmandu', + languages: ['Nepali'], + population: 28431500, + flag: 'https://restcountries.eu/data/npl.svg', + currency: 'Nepalese rupee' + }, + { + name: 'Netherlands', + capital: 'Amsterdam', + languages: ['Dutch'], + population: 17019800, + flag: 'https://restcountries.eu/data/nld.svg', + currency: 'Euro' + }, + { + name: 'New Caledonia', + capital: 'Nouméa', + languages: ['French'], + population: 268767, + flag: 'https://restcountries.eu/data/ncl.svg', + currency: 'CFP franc' + }, + { + name: 'New Zealand', + capital: 'Wellington', + languages: ['English', 'Māori'], + population: 4697854, + flag: 'https://restcountries.eu/data/nzl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Nicaragua', + capital: 'Managua', + languages: ['Spanish'], + population: 6262703, + flag: 'https://restcountries.eu/data/nic.svg', + currency: 'Nicaraguan córdoba' + }, + { + name: 'Niger', + capital: 'Niamey', + languages: ['French'], + population: 20715000, + flag: 'https://restcountries.eu/data/ner.svg', + currency: 'West African CFA franc' + }, + { + name: 'Nigeria', + capital: 'Abuja', + languages: ['English'], + population: 186988000, + flag: 'https://restcountries.eu/data/nga.svg', + currency: 'Nigerian naira' + }, + { + name: 'Niue', + capital: 'Alofi', + languages: ['English'], + population: 1470, + flag: 'https://restcountries.eu/data/niu.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Norfolk Island', + capital: 'Kingston', + languages: ['English'], + population: 2302, + flag: 'https://restcountries.eu/data/nfk.svg', + currency: 'Australian dollar' + }, + { + name: "Korea (Democratic People's Republic of)", + capital: 'Pyongyang', + languages: ['Korean'], + population: 25281000, + flag: 'https://restcountries.eu/data/prk.svg', + currency: 'North Korean won' + }, + { + name: 'Northern Mariana Islands', + capital: 'Saipan', + languages: ['English', 'Chamorro'], + population: 56940, + flag: 'https://restcountries.eu/data/mnp.svg', + currency: 'United States dollar' + }, + { + name: 'Norway', + capital: 'Oslo', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 5223256, + flag: 'https://restcountries.eu/data/nor.svg', + currency: 'Norwegian krone' + }, + { + name: 'Oman', + capital: 'Muscat', + languages: ['Arabic'], + population: 4420133, + flag: 'https://restcountries.eu/data/omn.svg', + currency: 'Omani rial' + }, + { + name: 'Pakistan', + capital: 'Islamabad', + languages: ['English', 'Urdu'], + population: 194125062, + flag: 'https://restcountries.eu/data/pak.svg', + currency: 'Pakistani rupee' + }, + { + name: 'Palau', + capital: 'Ngerulmud', + languages: ['English'], + population: 17950, + flag: 'https://restcountries.eu/data/plw.svg', + currency: '[E]' + }, + { + name: 'Palestine, State of', + capital: 'Ramallah', + languages: ['Arabic'], + population: 4682467, + flag: 'https://restcountries.eu/data/pse.svg', + currency: 'Israeli new sheqel' + }, + { + name: 'Panama', + capital: 'Panama City', + languages: ['Spanish'], + population: 3814672, + flag: 'https://restcountries.eu/data/pan.svg', + currency: 'Panamanian balboa' + }, + { + name: 'Papua New Guinea', + capital: 'Port Moresby', + languages: ['English'], + population: 8083700, + flag: 'https://restcountries.eu/data/png.svg', + currency: 'Papua New Guinean kina' + }, + { + name: 'Paraguay', + capital: 'Asunción', + languages: ['Spanish', 'Guaraní'], + population: 6854536, + flag: 'https://restcountries.eu/data/pry.svg', + currency: 'Paraguayan guaraní' + }, + { + name: 'Peru', + capital: 'Lima', + languages: ['Spanish'], + population: 31488700, + flag: 'https://restcountries.eu/data/per.svg', + currency: 'Peruvian sol' + }, + { + name: 'Philippines', + capital: 'Manila', + languages: ['English'], + population: 103279800, + flag: 'https://restcountries.eu/data/phl.svg', + currency: 'Philippine peso' + }, + { + name: 'Pitcairn', + capital: 'Adamstown', + languages: ['English'], + population: 56, + flag: 'https://restcountries.eu/data/pcn.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Poland', + capital: 'Warsaw', + languages: ['Polish'], + population: 38437239, + flag: 'https://restcountries.eu/data/pol.svg', + currency: 'Polish złoty' + }, + { + name: 'Portugal', + capital: 'Lisbon', + languages: ['Portuguese'], + population: 10374822, + flag: 'https://restcountries.eu/data/prt.svg', + currency: 'Euro' + }, + { + name: 'Puerto Rico', + capital: 'San Juan', + languages: ['Spanish', 'English'], + population: 3474182, + flag: 'https://restcountries.eu/data/pri.svg', + currency: 'United States dollar' + }, + { + name: 'Qatar', + capital: 'Doha', + languages: ['Arabic'], + population: 2587564, + flag: 'https://restcountries.eu/data/qat.svg', + currency: 'Qatari riyal' + }, + { + name: 'Republic of Kosovo', + capital: 'Pristina', + languages: ['Albanian', 'Serbian'], + population: 1733842, + flag: 'https://restcountries.eu/data/kos.svg', + currency: 'Euro' + }, + { + name: 'Réunion', + capital: 'Saint-Denis', + languages: ['French'], + population: 840974, + flag: 'https://restcountries.eu/data/reu.svg', + currency: 'Euro' + }, + { + name: 'Romania', + capital: 'Bucharest', + languages: ['Romanian'], + population: 19861408, + flag: 'https://restcountries.eu/data/rou.svg', + currency: 'Romanian leu' + }, + { + name: 'Russian Federation', + capital: 'Moscow', + languages: ['Russian'], + population: 146599183, + flag: 'https://restcountries.eu/data/rus.svg', + currency: 'Russian ruble' + }, + { + name: 'Rwanda', + capital: 'Kigali', + languages: ['Kinyarwanda', 'English', 'French'], + population: 11553188, + flag: 'https://restcountries.eu/data/rwa.svg', + currency: 'Rwandan franc' + }, + { + name: 'Saint Barthélemy', + capital: 'Gustavia', + languages: ['French'], + population: 9417, + flag: 'https://restcountries.eu/data/blm.svg', + currency: 'Euro' + }, + { + name: 'Saint Helena, Ascension and Tristan da Cunha', + capital: 'Jamestown', + languages: ['English'], + population: 4255, + flag: 'https://restcountries.eu/data/shn.svg', + currency: 'Saint Helena pound' + }, + { + name: 'Saint Kitts and Nevis', + capital: 'Basseterre', + languages: ['English'], + population: 46204, + flag: 'https://restcountries.eu/data/kna.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Lucia', + capital: 'Castries', + languages: ['English'], + population: 186000, + flag: 'https://restcountries.eu/data/lca.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Martin (French part)', + capital: 'Marigot', + languages: ['English', 'French', 'Dutch'], + population: 36979, + flag: 'https://restcountries.eu/data/maf.svg', + currency: 'Euro' + }, + { + name: 'Saint Pierre and Miquelon', + capital: 'Saint-Pierre', + languages: ['French'], + population: 6069, + flag: 'https://restcountries.eu/data/spm.svg', + currency: 'Euro' + }, + { + name: 'Saint Vincent and the Grenadines', + capital: 'Kingstown', + languages: ['English'], + population: 109991, + flag: 'https://restcountries.eu/data/vct.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Samoa', + capital: 'Apia', + languages: ['Samoan', 'English'], + population: 194899, + flag: 'https://restcountries.eu/data/wsm.svg', + currency: 'Samoan tālā' + }, + { + name: 'San Marino', + capital: 'City of San Marino', + languages: ['Italian'], + population: 33005, + flag: 'https://restcountries.eu/data/smr.svg', + currency: 'Euro' + }, + { + name: 'Sao Tome and Principe', + capital: 'São Tomé', + languages: ['Portuguese'], + population: 187356, + flag: 'https://restcountries.eu/data/stp.svg', + currency: 'São Tomé and Príncipe dobra' + }, + { + name: 'Saudi Arabia', + capital: 'Riyadh', + languages: ['Arabic'], + population: 32248200, + flag: 'https://restcountries.eu/data/sau.svg', + currency: 'Saudi riyal' + }, + { + name: 'Senegal', + capital: 'Dakar', + languages: ['French'], + population: 14799859, + flag: 'https://restcountries.eu/data/sen.svg', + currency: 'West African CFA franc' + }, + { + name: 'Serbia', + capital: 'Belgrade', + languages: ['Serbian'], + population: 7076372, + flag: 'https://restcountries.eu/data/srb.svg', + currency: 'Serbian dinar' + }, + { + name: 'Seychelles', + capital: 'Victoria', + languages: ['French', 'English'], + population: 91400, + flag: 'https://restcountries.eu/data/syc.svg', + currency: 'Seychellois rupee' + }, + { + name: 'Sierra Leone', + capital: 'Freetown', + languages: ['English'], + population: 7075641, + flag: 'https://restcountries.eu/data/sle.svg', + currency: 'Sierra Leonean leone' + }, + { + name: 'Singapore', + capital: 'Singapore', + languages: ['English', 'Malay', 'Tamil', 'Chinese'], + population: 5535000, + flag: 'https://restcountries.eu/data/sgp.svg', + currency: 'Brunei dollar' + }, + { + name: 'Sint Maarten (Dutch part)', + capital: 'Philipsburg', + languages: ['Dutch', 'English'], + population: 38247, + flag: 'https://restcountries.eu/data/sxm.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Slovakia', + capital: 'Bratislava', + languages: ['Slovak'], + population: 5426252, + flag: 'https://restcountries.eu/data/svk.svg', + currency: 'Euro' + }, + { + name: 'Slovenia', + capital: 'Ljubljana', + languages: ['Slovene'], + population: 2064188, + flag: 'https://restcountries.eu/data/svn.svg', + currency: 'Euro' + }, + { + name: 'Solomon Islands', + capital: 'Honiara', + languages: ['English'], + population: 642000, + flag: 'https://restcountries.eu/data/slb.svg', + currency: 'Solomon Islands dollar' + }, + { + name: 'Somalia', + capital: 'Mogadishu', + languages: ['Somali', 'Arabic'], + population: 11079000, + flag: 'https://restcountries.eu/data/som.svg', + currency: 'Somali shilling' + }, + { + name: 'South Africa', + capital: 'Pretoria', + languages: [ + 'Afrikaans', + 'English', + 'Southern Ndebele', + 'Southern Sotho', + 'Swati', + 'Tswana', + 'Tsonga', + 'Venda', + 'Xhosa', + 'Zulu' + ], + population: 55653654, + flag: 'https://restcountries.eu/data/zaf.svg', + currency: 'South African rand' + }, + { + name: 'South Georgia and the South Sandwich Islands', + capital: 'King Edward Point', + languages: ['English'], + population: 30, + flag: 'https://restcountries.eu/data/sgs.svg', + currency: 'British pound' + }, + { + name: 'Korea (Republic of)', + capital: 'Seoul', + languages: ['Korean'], + population: 50801405, + flag: 'https://restcountries.eu/data/kor.svg', + currency: 'South Korean won' + }, + { + name: 'South Sudan', + capital: 'Juba', + languages: ['English'], + population: 12131000, + flag: 'https://restcountries.eu/data/ssd.svg', + currency: 'South Sudanese pound' + }, + { + name: 'Spain', + capital: 'Madrid', + languages: ['Spanish'], + population: 46438422, + flag: 'https://restcountries.eu/data/esp.svg', + currency: 'Euro' + }, + { + name: 'Sri Lanka', + capital: 'Colombo', + languages: ['Sinhalese', 'Tamil'], + population: 20966000, + flag: 'https://restcountries.eu/data/lka.svg', + currency: 'Sri Lankan rupee' + }, + { + name: 'Sudan', + capital: 'Khartoum', + languages: ['Arabic', 'English'], + population: 39598700, + flag: 'https://restcountries.eu/data/sdn.svg', + currency: 'Sudanese pound' + }, + { + name: 'Suriname', + capital: 'Paramaribo', + languages: ['Dutch'], + population: 541638, + flag: 'https://restcountries.eu/data/sur.svg', + currency: 'Surinamese dollar' + }, + { + name: 'Svalbard and Jan Mayen', + capital: 'Longyearbyen', + languages: ['Norwegian'], + population: 2562, + flag: 'https://restcountries.eu/data/sjm.svg', + currency: 'Norwegian krone' + }, + { + name: 'Swaziland', + capital: 'Lobamba', + languages: ['English', 'Swati'], + population: 1132657, + flag: 'https://restcountries.eu/data/swz.svg', + currency: 'Swazi lilangeni' + }, + { + name: 'Sweden', + capital: 'Stockholm', + languages: ['Swedish'], + population: 9894888, + flag: 'https://restcountries.eu/data/swe.svg', + currency: 'Swedish krona' + }, + { + name: 'Switzerland', + capital: 'Bern', + languages: ['German', 'French', 'Italian'], + population: 8341600, + flag: 'https://restcountries.eu/data/che.svg', + currency: 'Swiss franc' + }, + { + name: 'Syrian Arab Republic', + capital: 'Damascus', + languages: ['Arabic'], + population: 18564000, + flag: 'https://restcountries.eu/data/syr.svg', + currency: 'Syrian pound' + }, + { + name: 'Taiwan', + capital: 'Taipei', + languages: ['Chinese'], + population: 23503349, + flag: 'https://restcountries.eu/data/twn.svg', + currency: 'New Taiwan dollar' + }, + { + name: 'Tajikistan', + capital: 'Dushanbe', + languages: ['Tajik', 'Russian'], + population: 8593600, + flag: 'https://restcountries.eu/data/tjk.svg', + currency: 'Tajikistani somoni' + }, + { + name: 'Tanzania, United Republic of', + capital: 'Dodoma', + languages: ['Swahili', 'English'], + population: 55155000, + flag: 'https://restcountries.eu/data/tza.svg', + currency: 'Tanzanian shilling' + }, + { + name: 'Thailand', + capital: 'Bangkok', + languages: ['Thai'], + population: 65327652, + flag: 'https://restcountries.eu/data/tha.svg', + currency: 'Thai baht' + }, + { + name: 'Timor-Leste', + capital: 'Dili', + languages: ['Portuguese'], + population: 1167242, + flag: 'https://restcountries.eu/data/tls.svg', + currency: 'United States dollar' + }, + { + name: 'Togo', + capital: 'Lomé', + languages: ['French'], + population: 7143000, + flag: 'https://restcountries.eu/data/tgo.svg', + currency: 'West African CFA franc' + }, + { + name: 'Tokelau', + capital: 'Fakaofo', + languages: ['English'], + population: 1411, + flag: 'https://restcountries.eu/data/tkl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Tonga', + capital: "Nuku'alofa", + languages: ['English', 'Tonga (Tonga Islands)'], + population: 103252, + flag: 'https://restcountries.eu/data/ton.svg', + currency: 'Tongan paʻanga' + }, + { + name: 'Trinidad and Tobago', + capital: 'Port of Spain', + languages: ['English'], + population: 1349667, + flag: 'https://restcountries.eu/data/tto.svg', + currency: 'Trinidad and Tobago dollar' + }, + { + name: 'Tunisia', + capital: 'Tunis', + languages: ['Arabic'], + population: 11154400, + flag: 'https://restcountries.eu/data/tun.svg', + currency: 'Tunisian dinar' + }, + { + name: 'Turkey', + capital: 'Ankara', + languages: ['Turkish'], + population: 78741053, + flag: 'https://restcountries.eu/data/tur.svg', + currency: 'Turkish lira' + }, + { + name: 'Turkmenistan', + capital: 'Ashgabat', + languages: ['Turkmen', 'Russian'], + population: 4751120, + flag: 'https://restcountries.eu/data/tkm.svg', + currency: 'Turkmenistan manat' + }, + { + name: 'Turks and Caicos Islands', + capital: 'Cockburn Town', + languages: ['English'], + population: 31458, + flag: 'https://restcountries.eu/data/tca.svg', + currency: 'United States dollar' + }, + { + name: 'Tuvalu', + capital: 'Funafuti', + languages: ['English'], + population: 10640, + flag: 'https://restcountries.eu/data/tuv.svg', + currency: 'Australian dollar' + }, + { + name: 'Uganda', + capital: 'Kampala', + languages: ['English', 'Swahili'], + population: 33860700, + flag: 'https://restcountries.eu/data/uga.svg', + currency: 'Ugandan shilling' + }, + { + name: 'Ukraine', + capital: 'Kiev', + languages: ['Ukrainian'], + population: 42692393, + flag: 'https://restcountries.eu/data/ukr.svg', + currency: 'Ukrainian hryvnia' + }, + { + name: 'United Arab Emirates', + capital: 'Abu Dhabi', + languages: ['Arabic'], + population: 9856000, + flag: 'https://restcountries.eu/data/are.svg', + currency: 'United Arab Emirates dirham' + }, + { + name: 'United Kingdom of Great Britain and Northern Ireland', + capital: 'London', + languages: ['English'], + population: 65110000, + flag: 'https://restcountries.eu/data/gbr.svg', + currency: 'British pound' + }, + { + name: 'United States of America', + capital: 'Washington, D.C.', + languages: ['English'], + population: 323947000, + flag: 'https://restcountries.eu/data/usa.svg', + currency: 'United States dollar' + }, + { + name: 'Uruguay', + capital: 'Montevideo', + languages: ['Spanish'], + population: 3480222, + flag: 'https://restcountries.eu/data/ury.svg', + currency: 'Uruguayan peso' + }, + { + name: 'Uzbekistan', + capital: 'Tashkent', + languages: ['Uzbek', 'Russian'], + population: 31576400, + flag: 'https://restcountries.eu/data/uzb.svg', + currency: "Uzbekistani so'm" + }, + { + name: 'Vanuatu', + capital: 'Port Vila', + languages: ['Bislama', 'English', 'French'], + population: 277500, + flag: 'https://restcountries.eu/data/vut.svg', + currency: 'Vanuatu vatu' + }, + { + name: 'Venezuela (Bolivarian Republic of)', + capital: 'Caracas', + languages: ['Spanish'], + population: 31028700, + flag: 'https://restcountries.eu/data/ven.svg', + currency: 'Venezuelan bolívar' + }, + { + name: 'Viet Nam', + capital: 'Hanoi', + languages: ['Vietnamese'], + population: 92700000, + flag: 'https://restcountries.eu/data/vnm.svg', + currency: 'Vietnamese đồng' + }, + { + name: 'Wallis and Futuna', + capital: 'Mata-Utu', + languages: ['French'], + population: 11750, + flag: 'https://restcountries.eu/data/wlf.svg', + currency: 'CFP franc' + }, + { + name: 'Western Sahara', + capital: 'El Aaiún', + languages: ['Spanish'], + population: 510713, + flag: 'https://restcountries.eu/data/esh.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Yemen', + capital: "Sana'a", + languages: ['Arabic'], + population: 27478000, + flag: 'https://restcountries.eu/data/yem.svg', + currency: 'Yemeni rial' + }, + { + name: 'Zambia', + capital: 'Lusaka', + languages: ['English'], + population: 15933883, + flag: 'https://restcountries.eu/data/zmb.svg', + currency: 'Zambian kwacha' + }, + { + name: 'Zimbabwe', + capital: 'Harare', + languages: ['English', 'Shona', 'Northern Ndebele'], + population: 14240168, + flag: 'https://restcountries.eu/data/zwe.svg', + currency: 'Botswana pula' + } +] diff --git a/15_Day_Classes/15_day_starter/index.html b/15_Day_Classes/15_day_starter/index.html new file mode 100644 index 0000000..db149cc --- /dev/null +++ b/15_Day_Classes/15_day_starter/index.html @@ -0,0 +1,17 @@ + + + + + 30DaysOfJavaScript:15 Day + + + +

30DaysOfJavaScript:15 Day

+

Classes

+ + + + + + + \ No newline at end of file diff --git a/15_Day_Classes/15_day_starter/scripts/main.js b/15_Day_Classes/15_day_starter/scripts/main.js new file mode 100644 index 0000000..4e66495 --- /dev/null +++ b/15_Day_Classes/15_day_starter/scripts/main.js @@ -0,0 +1,105 @@ + + +class Person { + constructor(firstName, lastName, age, country, city) { + this.firstName = firstName + this.lastName = lastName + this.age = age + this.country = country + this.city = city + this.score = 0 + this.skills = [] + } + getFullName() { + const fullName = this.firstName + ' ' + this.lastName + return fullName + } + get getScore() { + return this.score + } + get getSkills() { + return this.skills + } + set setScore(score) { + this.score += score + } + set setSkill(skill) { + this.skills.push(skill) + } + getPersonInfo() { + let fullName = this.getFullName() + let skills = + this.skills.length > 0 && + this.skills.slice(0, this.skills.length - 1).join(', ') + + ` and ${this.skills[this.skills.length - 1]}` + + let formattedSkills = skills ? `He knows ${skills}` : '' + + let info = `${fullName} is ${this.age}. He lives ${this.city}, ${this.country}. ${formattedSkills}` + console.log(this) + return info + } + static favoriteSkill() { + const skills = ['HTML', 'CSS', 'JS', 'React', 'Python', 'Node'] + const index = Math.floor(Math.random() * skills.length) + console.log('hi') + return skills[index] + } +} + +console.log(Person.favoriteSkill()) + +class Student extends Person { + constructor(firstName, lastName, age, country, city, gender) { + super(firstName, lastName, age, country, city) + this.gender = gender + } + + saySomething() { + console.log('I am a child of the person class') + } + getPersonInfo() { + let fullName = this.getFullName() + let skills = + this.skills.length > 0 && + this.skills.slice(0, this.skills.length - 1).join(', ') + + ` and ${this.skills[this.skills.length - 1]}` + + let formattedSkills = skills ? `He knows ${skills}` : '' + let pronoun = this.gender == 'Male' ? 'He' : 'She' + + let info = `${fullName} is ${this.age}. ${pronoun} lives in ${this.city}, ${this.country}. ${formattedSkills}` + console.log(this) + return info + } +} + +const s1 = new Student( + 'Asabeneh', + 'Yetayeh', + 250, + 'Finland', + 'Helsinki', + 'Male' +) +const s2 = new Student('Lidiya', 'Tekle', 28, 'Finland', 'Helsinki', 'Female') +s1.setScore = 1 +s1.setSkill = 'HTML' +s1.setSkill = 'CSS' +s1.setSkill = 'JavaScript' + +s2.setScore = 1 +s2.setSkill = 'Planning' +s2.setSkill = 'Managing' +s2.setSkill = 'Organizing' + +console.log(s1) +console.log(s2) + +console.log(s1.saySomething()) +console.log(s1.getFullName()) +console.log(s1.getPersonInfo()) + +console.log(s2.saySomething()) +console.log(s2.getFullName()) +console.log(s2.getPersonInfo()) \ No newline at end of file diff --git a/16_Day_JSON/16_day_json.md b/16_Day_JSON/16_day_json.md new file mode 100644 index 0000000..3cdfb40 --- /dev/null +++ b/16_Day_JSON/16_day_json.md @@ -0,0 +1,597 @@ +
+

30 Days Of JavaScript: JSON

+ + + + + Twitter Follow + + +Author: +Asabeneh Yetayeh
+ January, 2020 +
+ +
+ +[<< Day 15](../15_Day_Classes/15_day_classes.md) | [Day 17 >>](../17_Day_Web_storages/17_day_web_storages.md) + +![Thirty Days Of JavaScript](../images/banners/day_1_16.png) + +- [Day 16](#day-16) + - [JSON](#json) + - [Converting JSON to JavaScript Object](#converting-json-to-javascript-object) + - [JSON.parse()](#jsonparse) + - [Using a reviver function with JSON.parse()](#using-a-reviver-function-with-jsonparse) + - [Converting Object to JSON](#converting-object-to-json) + - [Using a Filter Array with JSON.stringify](#using-a-filter-array-with-jsonstringify) + - [Exercises](#exercises) + - [Exercises Level 1](#exercises-level-1) + - [Exercises Level 2](#exercises-level-2) + - [Exercises Level 3](#exercises-level-3) + +# Day 16 + +## JSON + +JSON stands for JavaScript Object Notation. The JSON syntax is derived from JavaScript object notation syntax, but the JSON format is text or string only. JSON is a light weight data format for storing and transporting. JSON is mostly used when data is sent from a server to a client. JSON is an easier-to-use alternative to XML. + +**Example:** + +```js +{ +"users":[ + { + "firstName":"Asabeneh", + "lastName":"Yetayeh", + "age":250, + "email":"asab@asb.com" + }, + { + "firstName":"Alex", + "lastName":"James", + "age":25, + "email":"alex@alex.com" + }, + { + "firstName":"Lidiya", + "lastName":"Tekle", + "age":28, + "email":"lidiya@lidiya.com" + } +] +} +``` + +The above JSON example is not much different for a normal object. Then, what is the difference ? The difference is the key of a JSON object should be with double quotes or it should be a string. JavaScript Object and JSON are very similar that we can change JSON to Object and Object to JSON. + +Let us see the above example in more detail, it starts with a curly bracket. Inside the curly bracket, there is "users" key which has a value array. Inside the array we have different objects and each objects has keys, each keys has to have double quotes. For instance, we use "firstNaMe" instead of just firstName, however in object we use keys without double quotes. This is the major difference between an object and a JSON. Let's see more examples about JSON. + +**Example:** + +```js +{ + "Alex": { + "email": "alex@alex.com", + "skills": [ + "HTML", + "CSS", + "JavaScript" + ], + "age": 20, + "isLoggedIn": false, + "points": 30 + }, + "Asab": { + "email": "asab@asab.com", + "skills": [ + "HTML", + "CSS", + "JavaScript", + "Redux", + "MongoDB", + "Express", + "React", + "Node" + ], + "age": 25, + "isLoggedIn": false, + "points": 50 + }, + "Brook": { + "email": "daniel@daniel.com", + "skills": [ + "HTML", + "CSS", + "JavaScript", + "React", + "Redux" + ], + "age": 30, + "isLoggedIn": true, + "points": 50 + }, + "Daniel": { + "email": "daniel@alex.com", + "skills": [ + "HTML", + "CSS", + "JavaScript", + "Python" + ], + "age": 20, + "isLoggedIn": false, + "points": 40 + }, + "John": { + "email": "john@john.com", + "skills": [ + "HTML", + "CSS", + "JavaScript", + "React", + "Redux", + "Node.js" + ], + "age": 20, + "isLoggedIn": true, + "points": 50 + }, + "Thomas": { + "email": "thomas@thomas.com", + "skills": [ + "HTML", + "CSS", + "JavaScript", + "React" + ], + "age": 20, + "isLoggedIn": false, + "points": 40 + }, + "Paul": { + "email": "paul@paul.com", + "skills": [ + "HTML", + "CSS", + "JavaScript", + "MongoDB", + "Express", + "React", + "Node" + ], + "age": 20, + "isLoggedIn": false, + "points": 40 + } +} +``` + +### Converting JSON to JavaScript Object + +Mostly we fetch JSON data from HTTP response or from a file, but we can store the JSON as a string and we can change to Object for sake of demonstration. In JavaScript the keyword _JSON_ has _parse()_ and _stringify()_ methods. When we want to change the JSON to an object we parse the JSON using _JSON.parse()_. When we want to change the object to JSON we use _JSON.stringify()_. + +#### JSON.parse() + +```js +JSON.parse(json[, reviver]) +// json or text , the data +// reviver is an optional callback function +``` + +```js +const usersText = `{ +"users":[ + { + "firstName":"Asabeneh", + "lastName":"Yetayeh", + "age":250, + "email":"asab@asb.com" + }, + { + "firstName":"Alex", + "lastName":"James", + "age":25, + "email":"alex@alex.com" + }, + { + "firstName":"Lidiya", + "lastName":"Tekle", + "age":28, + "email":"lidiya@lidiya.com" + } +] +}` + +const usersObj = JSON.parse(usersText, undefined, 4) +console.log(usersObj) +``` + +### Using a reviver function with JSON.parse() + +To use the reviver function as a formatter, we put the keys we want to format first name and last name value. Let us say, we are interested to format the firstName and lastName of the JSON data . + +```js +const usersText = `{ +"users":[ + { + "firstName":"Asabeneh", + "lastName":"Yetayeh", + "age":250, + "email":"asab@asb.com" + }, + { + "firstName":"Alex", + "lastName":"James", + "age":25, + "email":"alex@alex.com" + }, + { + "firstName":"Lidiya", + "lastName":"Tekle", + "age":28, + "email":"lidiya@lidiya.com" + } +] +}` + +const usersObj = JSON.parse(usersText, (key, value) => { + let newValue = + typeof value == 'string' && key != 'email' ? value.toUpperCase() : value + return newValue +}) +console.log(usersObj) +``` + +The _JSON.parse()_ is very handy to use. You do not have to pass optional parameter, you can just use it with the required parameter and you will achieve quite a lot. + +### Converting Object to JSON + +When we want to change the object to JSON we use _JSON.stringify()_. The stringify method takes one required parameter and two optional parameters. The replacer is used as filter and the space is an indentations. If we do not want to filter out any of the keys from the object we can just pass undefined. + +```js +JSON.stringify(obj, replacer, space) +// json or text , the data +// reviver is an optional callback function +``` + +Let us convert the following object to a string. First let use keep all the keys and also let us have 4 space indentation. + +```js +const users = { + Alex: { + email: 'alex@alex.com', + skills: ['HTML', 'CSS', 'JavaScript'], + age: 20, + isLoggedIn: false, + points: 30 + }, + Asab: { + email: 'asab@asab.com', + skills: [ + 'HTML', + 'CSS', + 'JavaScript', + 'Redux', + 'MongoDB', + 'Express', + 'React', + 'Node' + ], + age: 25, + isLoggedIn: false, + points: 50 + }, + Brook: { + email: 'daniel@daniel.com', + skills: ['HTML', 'CSS', 'JavaScript', 'React', 'Redux'], + age: 30, + isLoggedIn: true, + points: 50 + }, + Daniel: { + email: 'daniel@alex.com', + skills: ['HTML', 'CSS', 'JavaScript', 'Python'], + age: 20, + isLoggedIn: false, + points: 40 + }, + John: { + email: 'john@john.com', + skills: ['HTML', 'CSS', 'JavaScript', 'React', 'Redux', 'Node.js'], + age: 20, + isLoggedIn: true, + points: 50 + }, + Thomas: { + email: 'thomas@thomas.com', + skills: ['HTML', 'CSS', 'JavaScript', 'React'], + age: 20, + isLoggedIn: false, + points: 40 + }, + Paul: { + email: 'paul@paul.com', + skills: [ + 'HTML', + 'CSS', + 'JavaScript', + 'MongoDB', + 'Express', + 'React', + 'Node' + ], + age: 20, + isLoggedIn: false, + points: 40 + } +} + +const txt = JSON.stringify(users, undefined, 4) +console.log(txt) // text means JSON- because json is a string form of an object. +``` + +```sh +{ + "Alex": { + "email": "alex@alex.com", + "skills": [ + "HTML", + "CSS", + "JavaScript" + ], + "age": 20, + "isLoggedIn": false, + "points": 30 + }, + "Asab": { + "email": "asab@asab.com", + "skills": [ + "HTML", + "CSS", + "JavaScript", + "Redux", + "MongoDB", + "Express", + "React", + "Node" + ], + "age": 25, + "isLoggedIn": false, + "points": 50 + }, + "Brook": { + "email": "daniel@daniel.com", + "skills": [ + "HTML", + "CSS", + "JavaScript", + "React", + "Redux" + ], + "age": 30, + "isLoggedIn": true, + "points": 50 + }, + "Daniel": { + "email": "daniel@alex.com", + "skills": [ + "HTML", + "CSS", + "JavaScript", + "Python" + ], + "age": 20, + "isLoggedIn": false, + "points": 40 + }, + "John": { + "email": "john@john.com", + "skills": [ + "HTML", + "CSS", + "JavaScript", + "React", + "Redux", + "Node.js" + ], + "age": 20, + "isLoggedIn": true, + "points": 50 + }, + "Thomas": { + "email": "thomas@thomas.com", + "skills": [ + "HTML", + "CSS", + "JavaScript", + "React" + ], + "age": 20, + "isLoggedIn": false, + "points": 40 + }, + "Paul": { + "email": "paul@paul.com", + "skills": [ + "HTML", + "CSS", + "JavaScript", + "MongoDB", + "Express", + "React", + "Node" + ], + "age": 20, + "isLoggedIn": false, + "points": 40 + } +} +``` + +### Using a Filter Array with JSON.stringify + +Now, lets use the replacer as a filter. The user object has long list of keys but we are interested only in few of them. We put the keys we want to keep in array as show in the example and use it the place of the replacer. + +```js +const user = { + firstName: 'Asabeneh', + lastName: 'Yetayeh', + country: 'Finland', + city: 'Helsinki', + email: 'alex@alex.com', + skills: ['HTML', 'CSS', 'JavaScript', 'React', 'Pyhton'], + age: 250, + isLoggedIn: false, + points: 30 +} + +const txt = JSON.stringify(user,['firstName', 'lastName', 'country', 'city', 'age'],4) +console.log(txt) +``` + +```sh +{ + "firstName": "Asabeneh", + "lastName": "Yetayeh", + "country": "Finland", + "city": "Helsinki", + "age": 250 +} +``` + +🌕 You are extraordinary. Now, you knew a light-weight data format which you may use to store data or to send it an HTTP server. You are 16 steps a head to your way to greatness. Now do some exercises for your brain and for your muscle. + +## Exercises + +```js +const skills = ['HTML', 'CSS', 'JS', 'React','Node', 'Python'] +let age = 250; +let isMarried = true +const student = { + firstName:'Asabeneh', + lastName:'Yetayehe', + age:250, + isMarried:true, + skills:['HTML', 'CSS', 'JS', 'React','Node', 'Python', ] +} +const txt = `{ + "Alex": { + "email": "alex@alex.com", + "skills": [ + "HTML", + "CSS", + "JavaScript" + ], + "age": 20, + "isLoggedIn": false, + "points": 30 + }, + "Asab": { + "email": "asab@asab.com", + "skills": [ + "HTML", + "CSS", + "JavaScript", + "Redux", + "MongoDB", + "Express", + "React", + "Node" + ], + "age": 25, + "isLoggedIn": false, + "points": 50 + }, + "Brook": { + "email": "daniel@daniel.com", + "skills": [ + "HTML", + "CSS", + "JavaScript", + "React", + "Redux" + ], + "age": 30, + "isLoggedIn": true, + "points": 50 + }, + "Daniel": { + "email": "daniel@alex.com", + "skills": [ + "HTML", + "CSS", + "JavaScript", + "Python" + ], + "age": 20, + "isLoggedIn": false, + "points": 40 + }, + "John": { + "email": "john@john.com", + "skills": [ + "HTML", + "CSS", + "JavaScript", + "React", + "Redux", + "Node.js" + ], + "age": 20, + "isLoggedIn": true, + "points": 50 + }, + "Thomas": { + "email": "thomas@thomas.com", + "skills": [ + "HTML", + "CSS", + "JavaScript", + "React" + ], + "age": 20, + "isLoggedIn": false, + "points": 40 + }, + "Paul": { + "email": "paul@paul.com", + "skills": [ + "HTML", + "CSS", + "JavaScript", + "MongoDB", + "Express", + "React", + "Node" + ], + "age": 20, + "isLoggedIn": false, + "points": 40 + } +} +` +``` + +### Exercises Level 1 + +1. Change skills array to JSON using JSON.stringify() + +1. Stringify the age variable + +1. Stringify the isMarried variable + +1. Stringify the student object + +### Exercises Level 2 + +1. Stringify the students object with only firstName, lastName and skills properties + +### Exercises Level 3 + +1. Parse the *txt* JSON to object. +2. Find the the user who has many skills from the variable stored in *txt*. + +🎉 CONGRATULATIONS ! 🎉 + +[<< Day 15](../15_Day_Classes/15_day_classes.md) | [Day 17 >>](../17_Day_Web_storages/17_day_web_storages.md) diff --git a/16_Day_JSON/16_day_starter/data/countries_data.js b/16_Day_JSON/16_day_starter/data/countries_data.js new file mode 100644 index 0000000..92acddd --- /dev/null +++ b/16_Day_JSON/16_day_starter/data/countries_data.js @@ -0,0 +1,2013 @@ +const countries = [ + { + name: 'Afghanistan', + capital: 'Kabul', + languages: ['Pashto', 'Uzbek', 'Turkmen'], + population: 27657145, + flag: 'https://restcountries.eu/data/afg.svg', + currency: 'Afghan afghani' + }, + { + name: 'Åland Islands', + capital: 'Mariehamn', + languages: ['Swedish'], + population: 28875, + flag: 'https://restcountries.eu/data/ala.svg', + currency: 'Euro' + }, + { + name: 'Albania', + capital: 'Tirana', + languages: ['Albanian'], + population: 2886026, + flag: 'https://restcountries.eu/data/alb.svg', + currency: 'Albanian lek' + }, + { + name: 'Algeria', + capital: 'Algiers', + languages: ['Arabic'], + population: 40400000, + flag: 'https://restcountries.eu/data/dza.svg', + currency: 'Algerian dinar' + }, + { + name: 'American Samoa', + capital: 'Pago Pago', + languages: ['English', 'Samoan'], + population: 57100, + flag: 'https://restcountries.eu/data/asm.svg', + currency: 'United State Dollar' + }, + { + name: 'Andorra', + capital: 'Andorra la Vella', + languages: ['Catalan'], + population: 78014, + flag: 'https://restcountries.eu/data/and.svg', + currency: 'Euro' + }, + { + name: 'Angola', + capital: 'Luanda', + languages: ['Portuguese'], + population: 25868000, + flag: 'https://restcountries.eu/data/ago.svg', + currency: 'Angolan kwanza' + }, + { + name: 'Anguilla', + capital: 'The Valley', + languages: ['English'], + population: 13452, + flag: 'https://restcountries.eu/data/aia.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Antarctica', + capital: '', + languages: ['English', 'Russian'], + population: 1000, + flag: 'https://restcountries.eu/data/ata.svg', + currency: 'Australian dollar' + }, + { + name: 'Antigua and Barbuda', + capital: "Saint John's", + languages: ['English'], + population: 86295, + flag: 'https://restcountries.eu/data/atg.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Argentina', + capital: 'Buenos Aires', + languages: ['Spanish', 'Guaraní'], + population: 43590400, + flag: 'https://restcountries.eu/data/arg.svg', + currency: 'Argentine peso' + }, + { + name: 'Armenia', + capital: 'Yerevan', + languages: ['Armenian', 'Russian'], + population: 2994400, + flag: 'https://restcountries.eu/data/arm.svg', + currency: 'Armenian dram' + }, + { + name: 'Aruba', + capital: 'Oranjestad', + languages: ['Dutch', '(Eastern) Punjabi'], + population: 107394, + flag: 'https://restcountries.eu/data/abw.svg', + currency: 'Aruban florin' + }, + { + name: 'Australia', + capital: 'Canberra', + languages: ['English'], + population: 24117360, + flag: 'https://restcountries.eu/data/aus.svg', + currency: 'Australian dollar' + }, + { + name: 'Austria', + capital: 'Vienna', + languages: ['German'], + population: 8725931, + flag: 'https://restcountries.eu/data/aut.svg', + currency: 'Euro' + }, + { + name: 'Azerbaijan', + capital: 'Baku', + languages: ['Azerbaijani'], + population: 9730500, + flag: 'https://restcountries.eu/data/aze.svg', + currency: 'Azerbaijani manat' + }, + { + name: 'Bahamas', + capital: 'Nassau', + languages: ['English'], + population: 378040, + flag: 'https://restcountries.eu/data/bhs.svg', + currency: 'Bahamian dollar' + }, + { + name: 'Bahrain', + capital: 'Manama', + languages: ['Arabic'], + population: 1404900, + flag: 'https://restcountries.eu/data/bhr.svg', + currency: 'Bahraini dinar' + }, + { + name: 'Bangladesh', + capital: 'Dhaka', + languages: ['Bengali'], + population: 161006790, + flag: 'https://restcountries.eu/data/bgd.svg', + currency: 'Bangladeshi taka' + }, + { + name: 'Barbados', + capital: 'Bridgetown', + languages: ['English'], + population: 285000, + flag: 'https://restcountries.eu/data/brb.svg', + currency: 'Barbadian dollar' + }, + { + name: 'Belarus', + capital: 'Minsk', + languages: ['Belarusian', 'Russian'], + population: 9498700, + flag: 'https://restcountries.eu/data/blr.svg', + currency: 'New Belarusian ruble' + }, + { + name: 'Belgium', + capital: 'Brussels', + languages: ['Dutch', 'French', 'German'], + population: 11319511, + flag: 'https://restcountries.eu/data/bel.svg', + currency: 'Euro' + }, + { + name: 'Belize', + capital: 'Belmopan', + languages: ['English', 'Spanish'], + population: 370300, + flag: 'https://restcountries.eu/data/blz.svg', + currency: 'Belize dollar' + }, + { + name: 'Benin', + capital: 'Porto-Novo', + languages: ['French'], + population: 10653654, + flag: 'https://restcountries.eu/data/ben.svg', + currency: 'West African CFA franc' + }, + { + name: 'Bermuda', + capital: 'Hamilton', + languages: ['English'], + population: 61954, + flag: 'https://restcountries.eu/data/bmu.svg', + currency: 'Bermudian dollar' + }, + { + name: 'Bhutan', + capital: 'Thimphu', + languages: ['Dzongkha'], + population: 775620, + flag: 'https://restcountries.eu/data/btn.svg', + currency: 'Bhutanese ngultrum' + }, + { + name: 'Bolivia (Plurinational State of)', + capital: 'Sucre', + languages: ['Spanish', 'Aymara', 'Quechua'], + population: 10985059, + flag: 'https://restcountries.eu/data/bol.svg', + currency: 'Bolivian boliviano' + }, + { + name: 'Bonaire, Sint Eustatius and Saba', + capital: 'Kralendijk', + languages: ['Dutch'], + population: 17408, + flag: 'https://restcountries.eu/data/bes.svg', + currency: 'United States dollar' + }, + { + name: 'Bosnia and Herzegovina', + capital: 'Sarajevo', + languages: ['Bosnian', 'Croatian', 'Serbian'], + population: 3531159, + flag: 'https://restcountries.eu/data/bih.svg', + currency: 'Bosnia and Herzegovina convertible mark' + }, + { + name: 'Botswana', + capital: 'Gaborone', + languages: ['English', 'Tswana'], + population: 2141206, + flag: 'https://restcountries.eu/data/bwa.svg', + currency: 'Botswana pula' + }, + { + name: 'Bouvet Island', + capital: '', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 0, + flag: 'https://restcountries.eu/data/bvt.svg', + currency: 'Norwegian krone' + }, + { + name: 'Brazil', + capital: 'Brasília', + languages: ['Portuguese'], + population: 206135893, + flag: 'https://restcountries.eu/data/bra.svg', + currency: 'Brazilian real' + }, + { + name: 'British Indian Ocean Territory', + capital: 'Diego Garcia', + languages: ['English'], + population: 3000, + flag: 'https://restcountries.eu/data/iot.svg', + currency: 'United States dollar' + }, + { + name: 'United States Minor Outlying Islands', + capital: '', + languages: ['English'], + population: 300, + flag: 'https://restcountries.eu/data/umi.svg', + currency: 'United States Dollar' + }, + { + name: 'Virgin Islands (British)', + capital: 'Road Town', + languages: ['English'], + population: 28514, + flag: 'https://restcountries.eu/data/vgb.svg', + currency: '[D]' + }, + { + name: 'Virgin Islands (U.S.)', + capital: 'Charlotte Amalie', + languages: ['English'], + population: 114743, + flag: 'https://restcountries.eu/data/vir.svg', + currency: 'United States dollar' + }, + { + name: 'Brunei Darussalam', + capital: 'Bandar Seri Begawan', + languages: ['Malay'], + population: 411900, + flag: 'https://restcountries.eu/data/brn.svg', + currency: 'Brunei dollar' + }, + { + name: 'Bulgaria', + capital: 'Sofia', + languages: ['Bulgarian'], + population: 7153784, + flag: 'https://restcountries.eu/data/bgr.svg', + currency: 'Bulgarian lev' + }, + { + name: 'Burkina Faso', + capital: 'Ouagadougou', + languages: ['French', 'Fula'], + population: 19034397, + flag: 'https://restcountries.eu/data/bfa.svg', + currency: 'West African CFA franc' + }, + { + name: 'Burundi', + capital: 'Bujumbura', + languages: ['French', 'Kirundi'], + population: 10114505, + flag: 'https://restcountries.eu/data/bdi.svg', + currency: 'Burundian franc' + }, + { + name: 'Cambodia', + capital: 'Phnom Penh', + languages: ['Khmer'], + population: 15626444, + flag: 'https://restcountries.eu/data/khm.svg', + currency: 'Cambodian riel' + }, + { + name: 'Cameroon', + capital: 'Yaoundé', + languages: ['English', 'French'], + population: 22709892, + flag: 'https://restcountries.eu/data/cmr.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Canada', + capital: 'Ottawa', + languages: ['English', 'French'], + population: 36155487, + flag: 'https://restcountries.eu/data/can.svg', + currency: 'Canadian dollar' + }, + { + name: 'Cabo Verde', + capital: 'Praia', + languages: ['Portuguese'], + population: 531239, + flag: 'https://restcountries.eu/data/cpv.svg', + currency: 'Cape Verdean escudo' + }, + { + name: 'Cayman Islands', + capital: 'George Town', + languages: ['English'], + population: 58238, + flag: 'https://restcountries.eu/data/cym.svg', + currency: 'Cayman Islands dollar' + }, + { + name: 'Central African Republic', + capital: 'Bangui', + languages: ['French', 'Sango'], + population: 4998000, + flag: 'https://restcountries.eu/data/caf.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chad', + capital: "N'Djamena", + languages: ['French', 'Arabic'], + population: 14497000, + flag: 'https://restcountries.eu/data/tcd.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chile', + capital: 'Santiago', + languages: ['Spanish'], + population: 18191900, + flag: 'https://restcountries.eu/data/chl.svg', + currency: 'Chilean peso' + }, + { + name: 'China', + capital: 'Beijing', + languages: ['Chinese'], + population: 1377422166, + flag: 'https://restcountries.eu/data/chn.svg', + currency: 'Chinese yuan' + }, + { + name: 'Christmas Island', + capital: 'Flying Fish Cove', + languages: ['English'], + population: 2072, + flag: 'https://restcountries.eu/data/cxr.svg', + currency: 'Australian dollar' + }, + { + name: 'Cocos (Keeling) Islands', + capital: 'West Island', + languages: ['English'], + population: 550, + flag: 'https://restcountries.eu/data/cck.svg', + currency: 'Australian dollar' + }, + { + name: 'Colombia', + capital: 'Bogotá', + languages: ['Spanish'], + population: 48759958, + flag: 'https://restcountries.eu/data/col.svg', + currency: 'Colombian peso' + }, + { + name: 'Comoros', + capital: 'Moroni', + languages: ['Arabic', 'French'], + population: 806153, + flag: 'https://restcountries.eu/data/com.svg', + currency: 'Comorian franc' + }, + { + name: 'Congo', + capital: 'Brazzaville', + languages: ['French', 'Lingala'], + population: 4741000, + flag: 'https://restcountries.eu/data/cog.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Congo (Democratic Republic of the)', + capital: 'Kinshasa', + languages: ['French', 'Lingala', 'Kongo', 'Swahili', 'Luba-Katanga'], + population: 85026000, + flag: 'https://restcountries.eu/data/cod.svg', + currency: 'Congolese franc' + }, + { + name: 'Cook Islands', + capital: 'Avarua', + languages: ['English'], + population: 18100, + flag: 'https://restcountries.eu/data/cok.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Costa Rica', + capital: 'San José', + languages: ['Spanish'], + population: 4890379, + flag: 'https://restcountries.eu/data/cri.svg', + currency: 'Costa Rican colón' + }, + { + name: 'Croatia', + capital: 'Zagreb', + languages: ['Croatian'], + population: 4190669, + flag: 'https://restcountries.eu/data/hrv.svg', + currency: 'Croatian kuna' + }, + { + name: 'Cuba', + capital: 'Havana', + languages: ['Spanish'], + population: 11239004, + flag: 'https://restcountries.eu/data/cub.svg', + currency: 'Cuban convertible peso' + }, + { + name: 'Curaçao', + capital: 'Willemstad', + languages: ['Dutch', '(Eastern) Punjabi', 'English'], + population: 154843, + flag: 'https://restcountries.eu/data/cuw.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Cyprus', + capital: 'Nicosia', + languages: ['Greek (modern)', 'Turkish', 'Armenian'], + population: 847000, + flag: 'https://restcountries.eu/data/cyp.svg', + currency: 'Euro' + }, + { + name: 'Czech Republic', + capital: 'Prague', + languages: ['Czech', 'Slovak'], + population: 10558524, + flag: 'https://restcountries.eu/data/cze.svg', + currency: 'Czech koruna' + }, + { + name: 'Denmark', + capital: 'Copenhagen', + languages: ['Danish'], + population: 5717014, + flag: 'https://restcountries.eu/data/dnk.svg', + currency: 'Danish krone' + }, + { + name: 'Djibouti', + capital: 'Djibouti', + languages: ['French', 'Arabic'], + population: 900000, + flag: 'https://restcountries.eu/data/dji.svg', + currency: 'Djiboutian franc' + }, + { + name: 'Dominica', + capital: 'Roseau', + languages: ['English'], + population: 71293, + flag: 'https://restcountries.eu/data/dma.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Dominican Republic', + capital: 'Santo Domingo', + languages: ['Spanish'], + population: 10075045, + flag: 'https://restcountries.eu/data/dom.svg', + currency: 'Dominican peso' + }, + { + name: 'Ecuador', + capital: 'Quito', + languages: ['Spanish'], + population: 16545799, + flag: 'https://restcountries.eu/data/ecu.svg', + currency: 'United States dollar' + }, + { + name: 'Egypt', + capital: 'Cairo', + languages: ['Arabic'], + population: 91290000, + flag: 'https://restcountries.eu/data/egy.svg', + currency: 'Egyptian pound' + }, + { + name: 'El Salvador', + capital: 'San Salvador', + languages: ['Spanish'], + population: 6520675, + flag: 'https://restcountries.eu/data/slv.svg', + currency: 'United States dollar' + }, + { + name: 'Equatorial Guinea', + capital: 'Malabo', + languages: ['Spanish', 'French'], + population: 1222442, + flag: 'https://restcountries.eu/data/gnq.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Eritrea', + capital: 'Asmara', + languages: ['Tigrinya', 'Arabic', 'English'], + population: 5352000, + flag: 'https://restcountries.eu/data/eri.svg', + currency: 'Eritrean nakfa' + }, + { + name: 'Estonia', + capital: 'Tallinn', + languages: ['Estonian'], + population: 1315944, + flag: 'https://restcountries.eu/data/est.svg', + currency: 'Euro' + }, + { + name: 'Ethiopia', + capital: 'Addis Ababa', + languages: ['Amharic'], + population: 92206005, + flag: 'https://restcountries.eu/data/eth.svg', + currency: 'Ethiopian birr' + }, + { + name: 'Falkland Islands (Malvinas)', + capital: 'Stanley', + languages: ['English'], + population: 2563, + flag: 'https://restcountries.eu/data/flk.svg', + currency: 'Falkland Islands pound' + }, + { + name: 'Faroe Islands', + capital: 'Tórshavn', + languages: ['Faroese'], + population: 49376, + flag: 'https://restcountries.eu/data/fro.svg', + currency: 'Danish krone' + }, + { + name: 'Fiji', + capital: 'Suva', + languages: ['English', 'Fijian', 'Hindi', 'Urdu'], + population: 867000, + flag: 'https://restcountries.eu/data/fji.svg', + currency: 'Fijian dollar' + }, + { + name: 'Finland', + capital: 'Helsinki', + languages: ['Finnish', 'Swedish'], + population: 5491817, + flag: 'https://restcountries.eu/data/fin.svg', + currency: 'Euro' + }, + { + name: 'France', + capital: 'Paris', + languages: ['French'], + population: 66710000, + flag: 'https://restcountries.eu/data/fra.svg', + currency: 'Euro' + }, + { + name: 'French Guiana', + capital: 'Cayenne', + languages: ['French'], + population: 254541, + flag: 'https://restcountries.eu/data/guf.svg', + currency: 'Euro' + }, + { + name: 'French Polynesia', + capital: 'Papeetē', + languages: ['French'], + population: 271800, + flag: 'https://restcountries.eu/data/pyf.svg', + currency: 'CFP franc' + }, + { + name: 'French Southern Territories', + capital: 'Port-aux-Français', + languages: ['French'], + population: 140, + flag: 'https://restcountries.eu/data/atf.svg', + currency: 'Euro' + }, + { + name: 'Gabon', + capital: 'Libreville', + languages: ['French'], + population: 1802278, + flag: 'https://restcountries.eu/data/gab.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Gambia', + capital: 'Banjul', + languages: ['English'], + population: 1882450, + flag: 'https://restcountries.eu/data/gmb.svg', + currency: 'Gambian dalasi' + }, + { + name: 'Georgia', + capital: 'Tbilisi', + languages: ['Georgian'], + population: 3720400, + flag: 'https://restcountries.eu/data/geo.svg', + currency: 'Georgian Lari' + }, + { + name: 'Germany', + capital: 'Berlin', + languages: ['German'], + population: 81770900, + flag: 'https://restcountries.eu/data/deu.svg', + currency: 'Euro' + }, + { + name: 'Ghana', + capital: 'Accra', + languages: ['English'], + population: 27670174, + flag: 'https://restcountries.eu/data/gha.svg', + currency: 'Ghanaian cedi' + }, + { + name: 'Gibraltar', + capital: 'Gibraltar', + languages: ['English'], + population: 33140, + flag: 'https://restcountries.eu/data/gib.svg', + currency: 'Gibraltar pound' + }, + { + name: 'Greece', + capital: 'Athens', + languages: ['Greek (modern)'], + population: 10858018, + flag: 'https://restcountries.eu/data/grc.svg', + currency: 'Euro' + }, + { + name: 'Greenland', + capital: 'Nuuk', + languages: ['Kalaallisut'], + population: 55847, + flag: 'https://restcountries.eu/data/grl.svg', + currency: 'Danish krone' + }, + { + name: 'Grenada', + capital: "St. George's", + languages: ['English'], + population: 103328, + flag: 'https://restcountries.eu/data/grd.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Guadeloupe', + capital: 'Basse-Terre', + languages: ['French'], + population: 400132, + flag: 'https://restcountries.eu/data/glp.svg', + currency: 'Euro' + }, + { + name: 'Guam', + capital: 'Hagåtña', + languages: ['English', 'Chamorro', 'Spanish'], + population: 184200, + flag: 'https://restcountries.eu/data/gum.svg', + currency: 'United States dollar' + }, + { + name: 'Guatemala', + capital: 'Guatemala City', + languages: ['Spanish'], + population: 16176133, + flag: 'https://restcountries.eu/data/gtm.svg', + currency: 'Guatemalan quetzal' + }, + { + name: 'Guernsey', + capital: 'St. Peter Port', + languages: ['English', 'French'], + population: 62999, + flag: 'https://restcountries.eu/data/ggy.svg', + currency: 'British pound' + }, + { + name: 'Guinea', + capital: 'Conakry', + languages: ['French', 'Fula'], + population: 12947000, + flag: 'https://restcountries.eu/data/gin.svg', + currency: 'Guinean franc' + }, + { + name: 'Guinea-Bissau', + capital: 'Bissau', + languages: ['Portuguese'], + population: 1547777, + flag: 'https://restcountries.eu/data/gnb.svg', + currency: 'West African CFA franc' + }, + { + name: 'Guyana', + capital: 'Georgetown', + languages: ['English'], + population: 746900, + flag: 'https://restcountries.eu/data/guy.svg', + currency: 'Guyanese dollar' + }, + { + name: 'Haiti', + capital: 'Port-au-Prince', + languages: ['French', 'Haitian'], + population: 11078033, + flag: 'https://restcountries.eu/data/hti.svg', + currency: 'Haitian gourde' + }, + { + name: 'Heard Island and McDonald Islands', + capital: '', + languages: ['English'], + population: 0, + flag: 'https://restcountries.eu/data/hmd.svg', + currency: 'Australian dollar' + }, + { + name: 'Holy See', + capital: 'Rome', + languages: ['Latin', 'Italian', 'French', 'German'], + population: 451, + flag: 'https://restcountries.eu/data/vat.svg', + currency: 'Euro' + }, + { + name: 'Honduras', + capital: 'Tegucigalpa', + languages: ['Spanish'], + population: 8576532, + flag: 'https://restcountries.eu/data/hnd.svg', + currency: 'Honduran lempira' + }, + { + name: 'Hong Kong', + capital: 'City of Victoria', + languages: ['English', 'Chinese'], + population: 7324300, + flag: 'https://restcountries.eu/data/hkg.svg', + currency: 'Hong Kong dollar' + }, + { + name: 'Hungary', + capital: 'Budapest', + languages: ['Hungarian'], + population: 9823000, + flag: 'https://restcountries.eu/data/hun.svg', + currency: 'Hungarian forint' + }, + { + name: 'Iceland', + capital: 'Reykjavík', + languages: ['Icelandic'], + population: 334300, + flag: 'https://restcountries.eu/data/isl.svg', + currency: 'Icelandic króna' + }, + { + name: 'India', + capital: 'New Delhi', + languages: ['Hindi', 'English'], + population: 1295210000, + flag: 'https://restcountries.eu/data/ind.svg', + currency: 'Indian rupee' + }, + { + name: 'Indonesia', + capital: 'Jakarta', + languages: ['Indonesian'], + population: 258705000, + flag: 'https://restcountries.eu/data/idn.svg', + currency: 'Indonesian rupiah' + }, + { + name: "Côte d'Ivoire", + capital: 'Yamoussoukro', + languages: ['French'], + population: 22671331, + flag: 'https://restcountries.eu/data/civ.svg', + currency: 'West African CFA franc' + }, + { + name: 'Iran (Islamic Republic of)', + capital: 'Tehran', + languages: ['Persian (Farsi)'], + population: 79369900, + flag: 'https://restcountries.eu/data/irn.svg', + currency: 'Iranian rial' + }, + { + name: 'Iraq', + capital: 'Baghdad', + languages: ['Arabic', 'Kurdish'], + population: 37883543, + flag: 'https://restcountries.eu/data/irq.svg', + currency: 'Iraqi dinar' + }, + { + name: 'Ireland', + capital: 'Dublin', + languages: ['Irish', 'English'], + population: 6378000, + flag: 'https://restcountries.eu/data/irl.svg', + currency: 'Euro' + }, + { + name: 'Isle of Man', + capital: 'Douglas', + languages: ['English', 'Manx'], + population: 84497, + flag: 'https://restcountries.eu/data/imn.svg', + currency: 'British pound' + }, + { + name: 'Israel', + capital: 'Jerusalem', + languages: ['Hebrew (modern)', 'Arabic'], + population: 8527400, + flag: 'https://restcountries.eu/data/isr.svg', + currency: 'Israeli new shekel' + }, + { + name: 'Italy', + capital: 'Rome', + languages: ['Italian'], + population: 60665551, + flag: 'https://restcountries.eu/data/ita.svg', + currency: 'Euro' + }, + { + name: 'Jamaica', + capital: 'Kingston', + languages: ['English'], + population: 2723246, + flag: 'https://restcountries.eu/data/jam.svg', + currency: 'Jamaican dollar' + }, + { + name: 'Japan', + capital: 'Tokyo', + languages: ['Japanese'], + population: 126960000, + flag: 'https://restcountries.eu/data/jpn.svg', + currency: 'Japanese yen' + }, + { + name: 'Jersey', + capital: 'Saint Helier', + languages: ['English', 'French'], + population: 100800, + flag: 'https://restcountries.eu/data/jey.svg', + currency: 'British pound' + }, + { + name: 'Jordan', + capital: 'Amman', + languages: ['Arabic'], + population: 9531712, + flag: 'https://restcountries.eu/data/jor.svg', + currency: 'Jordanian dinar' + }, + { + name: 'Kazakhstan', + capital: 'Astana', + languages: ['Kazakh', 'Russian'], + population: 17753200, + flag: 'https://restcountries.eu/data/kaz.svg', + currency: 'Kazakhstani tenge' + }, + { + name: 'Kenya', + capital: 'Nairobi', + languages: ['English', 'Swahili'], + population: 47251000, + flag: 'https://restcountries.eu/data/ken.svg', + currency: 'Kenyan shilling' + }, + { + name: 'Kiribati', + capital: 'South Tarawa', + languages: ['English'], + population: 113400, + flag: 'https://restcountries.eu/data/kir.svg', + currency: 'Australian dollar' + }, + { + name: 'Kuwait', + capital: 'Kuwait City', + languages: ['Arabic'], + population: 4183658, + flag: 'https://restcountries.eu/data/kwt.svg', + currency: 'Kuwaiti dinar' + }, + { + name: 'Kyrgyzstan', + capital: 'Bishkek', + languages: ['Kyrgyz', 'Russian'], + population: 6047800, + flag: 'https://restcountries.eu/data/kgz.svg', + currency: 'Kyrgyzstani som' + }, + { + name: "Lao People's Democratic Republic", + capital: 'Vientiane', + languages: ['Lao'], + population: 6492400, + flag: 'https://restcountries.eu/data/lao.svg', + currency: 'Lao kip' + }, + { + name: 'Latvia', + capital: 'Riga', + languages: ['Latvian'], + population: 1961600, + flag: 'https://restcountries.eu/data/lva.svg', + currency: 'Euro' + }, + { + name: 'Lebanon', + capital: 'Beirut', + languages: ['Arabic', 'French'], + population: 5988000, + flag: 'https://restcountries.eu/data/lbn.svg', + currency: 'Lebanese pound' + }, + { + name: 'Lesotho', + capital: 'Maseru', + languages: ['English', 'Southern Sotho'], + population: 1894194, + flag: 'https://restcountries.eu/data/lso.svg', + currency: 'Lesotho loti' + }, + { + name: 'Liberia', + capital: 'Monrovia', + languages: ['English'], + population: 4615000, + flag: 'https://restcountries.eu/data/lbr.svg', + currency: 'Liberian dollar' + }, + { + name: 'Libya', + capital: 'Tripoli', + languages: ['Arabic'], + population: 6385000, + flag: 'https://restcountries.eu/data/lby.svg', + currency: 'Libyan dinar' + }, + { + name: 'Liechtenstein', + capital: 'Vaduz', + languages: ['German'], + population: 37623, + flag: 'https://restcountries.eu/data/lie.svg', + currency: 'Swiss franc' + }, + { + name: 'Lithuania', + capital: 'Vilnius', + languages: ['Lithuanian'], + population: 2872294, + flag: 'https://restcountries.eu/data/ltu.svg', + currency: 'Euro' + }, + { + name: 'Luxembourg', + capital: 'Luxembourg', + languages: ['French', 'German', 'Luxembourgish'], + population: 576200, + flag: 'https://restcountries.eu/data/lux.svg', + currency: 'Euro' + }, + { + name: 'Macao', + capital: '', + languages: ['Chinese', 'Portuguese'], + population: 649100, + flag: 'https://restcountries.eu/data/mac.svg', + currency: 'Macanese pataca' + }, + { + name: 'Macedonia (the former Yugoslav Republic of)', + capital: 'Skopje', + languages: ['Macedonian'], + population: 2058539, + flag: 'https://restcountries.eu/data/mkd.svg', + currency: 'Macedonian denar' + }, + { + name: 'Madagascar', + capital: 'Antananarivo', + languages: ['French', 'Malagasy'], + population: 22434363, + flag: 'https://restcountries.eu/data/mdg.svg', + currency: 'Malagasy ariary' + }, + { + name: 'Malawi', + capital: 'Lilongwe', + languages: ['English', 'Chichewa'], + population: 16832910, + flag: 'https://restcountries.eu/data/mwi.svg', + currency: 'Malawian kwacha' + }, + { + name: 'Malaysia', + capital: 'Kuala Lumpur', + languages: ['Malaysian'], + population: 31405416, + flag: 'https://restcountries.eu/data/mys.svg', + currency: 'Malaysian ringgit' + }, + { + name: 'Maldives', + capital: 'Malé', + languages: ['Divehi'], + population: 344023, + flag: 'https://restcountries.eu/data/mdv.svg', + currency: 'Maldivian rufiyaa' + }, + { + name: 'Mali', + capital: 'Bamako', + languages: ['French'], + population: 18135000, + flag: 'https://restcountries.eu/data/mli.svg', + currency: 'West African CFA franc' + }, + { + name: 'Malta', + capital: 'Valletta', + languages: ['Maltese', 'English'], + population: 425384, + flag: 'https://restcountries.eu/data/mlt.svg', + currency: 'Euro' + }, + { + name: 'Marshall Islands', + capital: 'Majuro', + languages: ['English', 'Marshallese'], + population: 54880, + flag: 'https://restcountries.eu/data/mhl.svg', + currency: 'United States dollar' + }, + { + name: 'Martinique', + capital: 'Fort-de-France', + languages: ['French'], + population: 378243, + flag: 'https://restcountries.eu/data/mtq.svg', + currency: 'Euro' + }, + { + name: 'Mauritania', + capital: 'Nouakchott', + languages: ['Arabic'], + population: 3718678, + flag: 'https://restcountries.eu/data/mrt.svg', + currency: 'Mauritanian ouguiya' + }, + { + name: 'Mauritius', + capital: 'Port Louis', + languages: ['English'], + population: 1262879, + flag: 'https://restcountries.eu/data/mus.svg', + currency: 'Mauritian rupee' + }, + { + name: 'Mayotte', + capital: 'Mamoudzou', + languages: ['French'], + population: 226915, + flag: 'https://restcountries.eu/data/myt.svg', + currency: 'Euro' + }, + { + name: 'Mexico', + capital: 'Mexico City', + languages: ['Spanish'], + population: 122273473, + flag: 'https://restcountries.eu/data/mex.svg', + currency: 'Mexican peso' + }, + { + name: 'Micronesia (Federated States of)', + capital: 'Palikir', + languages: ['English'], + population: 102800, + flag: 'https://restcountries.eu/data/fsm.svg', + currency: '[D]' + }, + { + name: 'Moldova (Republic of)', + capital: 'Chișinău', + languages: ['Romanian'], + population: 3553100, + flag: 'https://restcountries.eu/data/mda.svg', + currency: 'Moldovan leu' + }, + { + name: 'Monaco', + capital: 'Monaco', + languages: ['French'], + population: 38400, + flag: 'https://restcountries.eu/data/mco.svg', + currency: 'Euro' + }, + { + name: 'Mongolia', + capital: 'Ulan Bator', + languages: ['Mongolian'], + population: 3093100, + flag: 'https://restcountries.eu/data/mng.svg', + currency: 'Mongolian tögrög' + }, + { + name: 'Montenegro', + capital: 'Podgorica', + languages: ['Serbian', 'Bosnian', 'Albanian', 'Croatian'], + population: 621810, + flag: 'https://restcountries.eu/data/mne.svg', + currency: 'Euro' + }, + { + name: 'Montserrat', + capital: 'Plymouth', + languages: ['English'], + population: 4922, + flag: 'https://restcountries.eu/data/msr.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Morocco', + capital: 'Rabat', + languages: ['Arabic'], + population: 33337529, + flag: 'https://restcountries.eu/data/mar.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Mozambique', + capital: 'Maputo', + languages: ['Portuguese'], + population: 26423700, + flag: 'https://restcountries.eu/data/moz.svg', + currency: 'Mozambican metical' + }, + { + name: 'Myanmar', + capital: 'Naypyidaw', + languages: ['Burmese'], + population: 51419420, + flag: 'https://restcountries.eu/data/mmr.svg', + currency: 'Burmese kyat' + }, + { + name: 'Namibia', + capital: 'Windhoek', + languages: ['English', 'Afrikaans'], + population: 2324388, + flag: 'https://restcountries.eu/data/nam.svg', + currency: 'Namibian dollar' + }, + { + name: 'Nauru', + capital: 'Yaren', + languages: ['English', 'Nauruan'], + population: 10084, + flag: 'https://restcountries.eu/data/nru.svg', + currency: 'Australian dollar' + }, + { + name: 'Nepal', + capital: 'Kathmandu', + languages: ['Nepali'], + population: 28431500, + flag: 'https://restcountries.eu/data/npl.svg', + currency: 'Nepalese rupee' + }, + { + name: 'Netherlands', + capital: 'Amsterdam', + languages: ['Dutch'], + population: 17019800, + flag: 'https://restcountries.eu/data/nld.svg', + currency: 'Euro' + }, + { + name: 'New Caledonia', + capital: 'Nouméa', + languages: ['French'], + population: 268767, + flag: 'https://restcountries.eu/data/ncl.svg', + currency: 'CFP franc' + }, + { + name: 'New Zealand', + capital: 'Wellington', + languages: ['English', 'Māori'], + population: 4697854, + flag: 'https://restcountries.eu/data/nzl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Nicaragua', + capital: 'Managua', + languages: ['Spanish'], + population: 6262703, + flag: 'https://restcountries.eu/data/nic.svg', + currency: 'Nicaraguan córdoba' + }, + { + name: 'Niger', + capital: 'Niamey', + languages: ['French'], + population: 20715000, + flag: 'https://restcountries.eu/data/ner.svg', + currency: 'West African CFA franc' + }, + { + name: 'Nigeria', + capital: 'Abuja', + languages: ['English'], + population: 186988000, + flag: 'https://restcountries.eu/data/nga.svg', + currency: 'Nigerian naira' + }, + { + name: 'Niue', + capital: 'Alofi', + languages: ['English'], + population: 1470, + flag: 'https://restcountries.eu/data/niu.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Norfolk Island', + capital: 'Kingston', + languages: ['English'], + population: 2302, + flag: 'https://restcountries.eu/data/nfk.svg', + currency: 'Australian dollar' + }, + { + name: "Korea (Democratic People's Republic of)", + capital: 'Pyongyang', + languages: ['Korean'], + population: 25281000, + flag: 'https://restcountries.eu/data/prk.svg', + currency: 'North Korean won' + }, + { + name: 'Northern Mariana Islands', + capital: 'Saipan', + languages: ['English', 'Chamorro'], + population: 56940, + flag: 'https://restcountries.eu/data/mnp.svg', + currency: 'United States dollar' + }, + { + name: 'Norway', + capital: 'Oslo', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 5223256, + flag: 'https://restcountries.eu/data/nor.svg', + currency: 'Norwegian krone' + }, + { + name: 'Oman', + capital: 'Muscat', + languages: ['Arabic'], + population: 4420133, + flag: 'https://restcountries.eu/data/omn.svg', + currency: 'Omani rial' + }, + { + name: 'Pakistan', + capital: 'Islamabad', + languages: ['English', 'Urdu'], + population: 194125062, + flag: 'https://restcountries.eu/data/pak.svg', + currency: 'Pakistani rupee' + }, + { + name: 'Palau', + capital: 'Ngerulmud', + languages: ['English'], + population: 17950, + flag: 'https://restcountries.eu/data/plw.svg', + currency: '[E]' + }, + { + name: 'Palestine, State of', + capital: 'Ramallah', + languages: ['Arabic'], + population: 4682467, + flag: 'https://restcountries.eu/data/pse.svg', + currency: 'Israeli new sheqel' + }, + { + name: 'Panama', + capital: 'Panama City', + languages: ['Spanish'], + population: 3814672, + flag: 'https://restcountries.eu/data/pan.svg', + currency: 'Panamanian balboa' + }, + { + name: 'Papua New Guinea', + capital: 'Port Moresby', + languages: ['English'], + population: 8083700, + flag: 'https://restcountries.eu/data/png.svg', + currency: 'Papua New Guinean kina' + }, + { + name: 'Paraguay', + capital: 'Asunción', + languages: ['Spanish', 'Guaraní'], + population: 6854536, + flag: 'https://restcountries.eu/data/pry.svg', + currency: 'Paraguayan guaraní' + }, + { + name: 'Peru', + capital: 'Lima', + languages: ['Spanish'], + population: 31488700, + flag: 'https://restcountries.eu/data/per.svg', + currency: 'Peruvian sol' + }, + { + name: 'Philippines', + capital: 'Manila', + languages: ['English'], + population: 103279800, + flag: 'https://restcountries.eu/data/phl.svg', + currency: 'Philippine peso' + }, + { + name: 'Pitcairn', + capital: 'Adamstown', + languages: ['English'], + population: 56, + flag: 'https://restcountries.eu/data/pcn.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Poland', + capital: 'Warsaw', + languages: ['Polish'], + population: 38437239, + flag: 'https://restcountries.eu/data/pol.svg', + currency: 'Polish złoty' + }, + { + name: 'Portugal', + capital: 'Lisbon', + languages: ['Portuguese'], + population: 10374822, + flag: 'https://restcountries.eu/data/prt.svg', + currency: 'Euro' + }, + { + name: 'Puerto Rico', + capital: 'San Juan', + languages: ['Spanish', 'English'], + population: 3474182, + flag: 'https://restcountries.eu/data/pri.svg', + currency: 'United States dollar' + }, + { + name: 'Qatar', + capital: 'Doha', + languages: ['Arabic'], + population: 2587564, + flag: 'https://restcountries.eu/data/qat.svg', + currency: 'Qatari riyal' + }, + { + name: 'Republic of Kosovo', + capital: 'Pristina', + languages: ['Albanian', 'Serbian'], + population: 1733842, + flag: 'https://restcountries.eu/data/kos.svg', + currency: 'Euro' + }, + { + name: 'Réunion', + capital: 'Saint-Denis', + languages: ['French'], + population: 840974, + flag: 'https://restcountries.eu/data/reu.svg', + currency: 'Euro' + }, + { + name: 'Romania', + capital: 'Bucharest', + languages: ['Romanian'], + population: 19861408, + flag: 'https://restcountries.eu/data/rou.svg', + currency: 'Romanian leu' + }, + { + name: 'Russian Federation', + capital: 'Moscow', + languages: ['Russian'], + population: 146599183, + flag: 'https://restcountries.eu/data/rus.svg', + currency: 'Russian ruble' + }, + { + name: 'Rwanda', + capital: 'Kigali', + languages: ['Kinyarwanda', 'English', 'French'], + population: 11553188, + flag: 'https://restcountries.eu/data/rwa.svg', + currency: 'Rwandan franc' + }, + { + name: 'Saint Barthélemy', + capital: 'Gustavia', + languages: ['French'], + population: 9417, + flag: 'https://restcountries.eu/data/blm.svg', + currency: 'Euro' + }, + { + name: 'Saint Helena, Ascension and Tristan da Cunha', + capital: 'Jamestown', + languages: ['English'], + population: 4255, + flag: 'https://restcountries.eu/data/shn.svg', + currency: 'Saint Helena pound' + }, + { + name: 'Saint Kitts and Nevis', + capital: 'Basseterre', + languages: ['English'], + population: 46204, + flag: 'https://restcountries.eu/data/kna.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Lucia', + capital: 'Castries', + languages: ['English'], + population: 186000, + flag: 'https://restcountries.eu/data/lca.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Martin (French part)', + capital: 'Marigot', + languages: ['English', 'French', 'Dutch'], + population: 36979, + flag: 'https://restcountries.eu/data/maf.svg', + currency: 'Euro' + }, + { + name: 'Saint Pierre and Miquelon', + capital: 'Saint-Pierre', + languages: ['French'], + population: 6069, + flag: 'https://restcountries.eu/data/spm.svg', + currency: 'Euro' + }, + { + name: 'Saint Vincent and the Grenadines', + capital: 'Kingstown', + languages: ['English'], + population: 109991, + flag: 'https://restcountries.eu/data/vct.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Samoa', + capital: 'Apia', + languages: ['Samoan', 'English'], + population: 194899, + flag: 'https://restcountries.eu/data/wsm.svg', + currency: 'Samoan tālā' + }, + { + name: 'San Marino', + capital: 'City of San Marino', + languages: ['Italian'], + population: 33005, + flag: 'https://restcountries.eu/data/smr.svg', + currency: 'Euro' + }, + { + name: 'Sao Tome and Principe', + capital: 'São Tomé', + languages: ['Portuguese'], + population: 187356, + flag: 'https://restcountries.eu/data/stp.svg', + currency: 'São Tomé and Príncipe dobra' + }, + { + name: 'Saudi Arabia', + capital: 'Riyadh', + languages: ['Arabic'], + population: 32248200, + flag: 'https://restcountries.eu/data/sau.svg', + currency: 'Saudi riyal' + }, + { + name: 'Senegal', + capital: 'Dakar', + languages: ['French'], + population: 14799859, + flag: 'https://restcountries.eu/data/sen.svg', + currency: 'West African CFA franc' + }, + { + name: 'Serbia', + capital: 'Belgrade', + languages: ['Serbian'], + population: 7076372, + flag: 'https://restcountries.eu/data/srb.svg', + currency: 'Serbian dinar' + }, + { + name: 'Seychelles', + capital: 'Victoria', + languages: ['French', 'English'], + population: 91400, + flag: 'https://restcountries.eu/data/syc.svg', + currency: 'Seychellois rupee' + }, + { + name: 'Sierra Leone', + capital: 'Freetown', + languages: ['English'], + population: 7075641, + flag: 'https://restcountries.eu/data/sle.svg', + currency: 'Sierra Leonean leone' + }, + { + name: 'Singapore', + capital: 'Singapore', + languages: ['English', 'Malay', 'Tamil', 'Chinese'], + population: 5535000, + flag: 'https://restcountries.eu/data/sgp.svg', + currency: 'Brunei dollar' + }, + { + name: 'Sint Maarten (Dutch part)', + capital: 'Philipsburg', + languages: ['Dutch', 'English'], + population: 38247, + flag: 'https://restcountries.eu/data/sxm.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Slovakia', + capital: 'Bratislava', + languages: ['Slovak'], + population: 5426252, + flag: 'https://restcountries.eu/data/svk.svg', + currency: 'Euro' + }, + { + name: 'Slovenia', + capital: 'Ljubljana', + languages: ['Slovene'], + population: 2064188, + flag: 'https://restcountries.eu/data/svn.svg', + currency: 'Euro' + }, + { + name: 'Solomon Islands', + capital: 'Honiara', + languages: ['English'], + population: 642000, + flag: 'https://restcountries.eu/data/slb.svg', + currency: 'Solomon Islands dollar' + }, + { + name: 'Somalia', + capital: 'Mogadishu', + languages: ['Somali', 'Arabic'], + population: 11079000, + flag: 'https://restcountries.eu/data/som.svg', + currency: 'Somali shilling' + }, + { + name: 'South Africa', + capital: 'Pretoria', + languages: [ + 'Afrikaans', + 'English', + 'Southern Ndebele', + 'Southern Sotho', + 'Swati', + 'Tswana', + 'Tsonga', + 'Venda', + 'Xhosa', + 'Zulu' + ], + population: 55653654, + flag: 'https://restcountries.eu/data/zaf.svg', + currency: 'South African rand' + }, + { + name: 'South Georgia and the South Sandwich Islands', + capital: 'King Edward Point', + languages: ['English'], + population: 30, + flag: 'https://restcountries.eu/data/sgs.svg', + currency: 'British pound' + }, + { + name: 'Korea (Republic of)', + capital: 'Seoul', + languages: ['Korean'], + population: 50801405, + flag: 'https://restcountries.eu/data/kor.svg', + currency: 'South Korean won' + }, + { + name: 'South Sudan', + capital: 'Juba', + languages: ['English'], + population: 12131000, + flag: 'https://restcountries.eu/data/ssd.svg', + currency: 'South Sudanese pound' + }, + { + name: 'Spain', + capital: 'Madrid', + languages: ['Spanish'], + population: 46438422, + flag: 'https://restcountries.eu/data/esp.svg', + currency: 'Euro' + }, + { + name: 'Sri Lanka', + capital: 'Colombo', + languages: ['Sinhalese', 'Tamil'], + population: 20966000, + flag: 'https://restcountries.eu/data/lka.svg', + currency: 'Sri Lankan rupee' + }, + { + name: 'Sudan', + capital: 'Khartoum', + languages: ['Arabic', 'English'], + population: 39598700, + flag: 'https://restcountries.eu/data/sdn.svg', + currency: 'Sudanese pound' + }, + { + name: 'Suriname', + capital: 'Paramaribo', + languages: ['Dutch'], + population: 541638, + flag: 'https://restcountries.eu/data/sur.svg', + currency: 'Surinamese dollar' + }, + { + name: 'Svalbard and Jan Mayen', + capital: 'Longyearbyen', + languages: ['Norwegian'], + population: 2562, + flag: 'https://restcountries.eu/data/sjm.svg', + currency: 'Norwegian krone' + }, + { + name: 'Swaziland', + capital: 'Lobamba', + languages: ['English', 'Swati'], + population: 1132657, + flag: 'https://restcountries.eu/data/swz.svg', + currency: 'Swazi lilangeni' + }, + { + name: 'Sweden', + capital: 'Stockholm', + languages: ['Swedish'], + population: 9894888, + flag: 'https://restcountries.eu/data/swe.svg', + currency: 'Swedish krona' + }, + { + name: 'Switzerland', + capital: 'Bern', + languages: ['German', 'French', 'Italian'], + population: 8341600, + flag: 'https://restcountries.eu/data/che.svg', + currency: 'Swiss franc' + }, + { + name: 'Syrian Arab Republic', + capital: 'Damascus', + languages: ['Arabic'], + population: 18564000, + flag: 'https://restcountries.eu/data/syr.svg', + currency: 'Syrian pound' + }, + { + name: 'Taiwan', + capital: 'Taipei', + languages: ['Chinese'], + population: 23503349, + flag: 'https://restcountries.eu/data/twn.svg', + currency: 'New Taiwan dollar' + }, + { + name: 'Tajikistan', + capital: 'Dushanbe', + languages: ['Tajik', 'Russian'], + population: 8593600, + flag: 'https://restcountries.eu/data/tjk.svg', + currency: 'Tajikistani somoni' + }, + { + name: 'Tanzania, United Republic of', + capital: 'Dodoma', + languages: ['Swahili', 'English'], + population: 55155000, + flag: 'https://restcountries.eu/data/tza.svg', + currency: 'Tanzanian shilling' + }, + { + name: 'Thailand', + capital: 'Bangkok', + languages: ['Thai'], + population: 65327652, + flag: 'https://restcountries.eu/data/tha.svg', + currency: 'Thai baht' + }, + { + name: 'Timor-Leste', + capital: 'Dili', + languages: ['Portuguese'], + population: 1167242, + flag: 'https://restcountries.eu/data/tls.svg', + currency: 'United States dollar' + }, + { + name: 'Togo', + capital: 'Lomé', + languages: ['French'], + population: 7143000, + flag: 'https://restcountries.eu/data/tgo.svg', + currency: 'West African CFA franc' + }, + { + name: 'Tokelau', + capital: 'Fakaofo', + languages: ['English'], + population: 1411, + flag: 'https://restcountries.eu/data/tkl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Tonga', + capital: "Nuku'alofa", + languages: ['English', 'Tonga (Tonga Islands)'], + population: 103252, + flag: 'https://restcountries.eu/data/ton.svg', + currency: 'Tongan paʻanga' + }, + { + name: 'Trinidad and Tobago', + capital: 'Port of Spain', + languages: ['English'], + population: 1349667, + flag: 'https://restcountries.eu/data/tto.svg', + currency: 'Trinidad and Tobago dollar' + }, + { + name: 'Tunisia', + capital: 'Tunis', + languages: ['Arabic'], + population: 11154400, + flag: 'https://restcountries.eu/data/tun.svg', + currency: 'Tunisian dinar' + }, + { + name: 'Turkey', + capital: 'Ankara', + languages: ['Turkish'], + population: 78741053, + flag: 'https://restcountries.eu/data/tur.svg', + currency: 'Turkish lira' + }, + { + name: 'Turkmenistan', + capital: 'Ashgabat', + languages: ['Turkmen', 'Russian'], + population: 4751120, + flag: 'https://restcountries.eu/data/tkm.svg', + currency: 'Turkmenistan manat' + }, + { + name: 'Turks and Caicos Islands', + capital: 'Cockburn Town', + languages: ['English'], + population: 31458, + flag: 'https://restcountries.eu/data/tca.svg', + currency: 'United States dollar' + }, + { + name: 'Tuvalu', + capital: 'Funafuti', + languages: ['English'], + population: 10640, + flag: 'https://restcountries.eu/data/tuv.svg', + currency: 'Australian dollar' + }, + { + name: 'Uganda', + capital: 'Kampala', + languages: ['English', 'Swahili'], + population: 33860700, + flag: 'https://restcountries.eu/data/uga.svg', + currency: 'Ugandan shilling' + }, + { + name: 'Ukraine', + capital: 'Kiev', + languages: ['Ukrainian'], + population: 42692393, + flag: 'https://restcountries.eu/data/ukr.svg', + currency: 'Ukrainian hryvnia' + }, + { + name: 'United Arab Emirates', + capital: 'Abu Dhabi', + languages: ['Arabic'], + population: 9856000, + flag: 'https://restcountries.eu/data/are.svg', + currency: 'United Arab Emirates dirham' + }, + { + name: 'United Kingdom of Great Britain and Northern Ireland', + capital: 'London', + languages: ['English'], + population: 65110000, + flag: 'https://restcountries.eu/data/gbr.svg', + currency: 'British pound' + }, + { + name: 'United States of America', + capital: 'Washington, D.C.', + languages: ['English'], + population: 323947000, + flag: 'https://restcountries.eu/data/usa.svg', + currency: 'United States dollar' + }, + { + name: 'Uruguay', + capital: 'Montevideo', + languages: ['Spanish'], + population: 3480222, + flag: 'https://restcountries.eu/data/ury.svg', + currency: 'Uruguayan peso' + }, + { + name: 'Uzbekistan', + capital: 'Tashkent', + languages: ['Uzbek', 'Russian'], + population: 31576400, + flag: 'https://restcountries.eu/data/uzb.svg', + currency: "Uzbekistani so'm" + }, + { + name: 'Vanuatu', + capital: 'Port Vila', + languages: ['Bislama', 'English', 'French'], + population: 277500, + flag: 'https://restcountries.eu/data/vut.svg', + currency: 'Vanuatu vatu' + }, + { + name: 'Venezuela (Bolivarian Republic of)', + capital: 'Caracas', + languages: ['Spanish'], + population: 31028700, + flag: 'https://restcountries.eu/data/ven.svg', + currency: 'Venezuelan bolívar' + }, + { + name: 'Viet Nam', + capital: 'Hanoi', + languages: ['Vietnamese'], + population: 92700000, + flag: 'https://restcountries.eu/data/vnm.svg', + currency: 'Vietnamese đồng' + }, + { + name: 'Wallis and Futuna', + capital: 'Mata-Utu', + languages: ['French'], + population: 11750, + flag: 'https://restcountries.eu/data/wlf.svg', + currency: 'CFP franc' + }, + { + name: 'Western Sahara', + capital: 'El Aaiún', + languages: ['Spanish'], + population: 510713, + flag: 'https://restcountries.eu/data/esh.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Yemen', + capital: "Sana'a", + languages: ['Arabic'], + population: 27478000, + flag: 'https://restcountries.eu/data/yem.svg', + currency: 'Yemeni rial' + }, + { + name: 'Zambia', + capital: 'Lusaka', + languages: ['English'], + population: 15933883, + flag: 'https://restcountries.eu/data/zmb.svg', + currency: 'Zambian kwacha' + }, + { + name: 'Zimbabwe', + capital: 'Harare', + languages: ['English', 'Shona', 'Northern Ndebele'], + population: 14240168, + flag: 'https://restcountries.eu/data/zwe.svg', + currency: 'Botswana pula' + } +] diff --git a/16_Day_JSON/16_day_starter/index.html b/16_Day_JSON/16_day_starter/index.html new file mode 100644 index 0000000..53d732a --- /dev/null +++ b/16_Day_JSON/16_day_starter/index.html @@ -0,0 +1,17 @@ + + + + + 30DaysOfJavaScript:16 Day + + + +

30DaysOfJavaScript:16 Day

+

JSON

+ + + + + + + \ No newline at end of file diff --git a/16_Day_JSON/16_day_starter/scripts/main.js b/16_Day_JSON/16_day_starter/scripts/main.js new file mode 100644 index 0000000..c6045c8 --- /dev/null +++ b/16_Day_JSON/16_day_starter/scripts/main.js @@ -0,0 +1,2 @@ +console.log(countries) +alert('Open the console and check if the countries has been loaded') \ No newline at end of file diff --git a/17_Day_Web_storages/17_day_starter/data/countries_data.js b/17_Day_Web_storages/17_day_starter/data/countries_data.js new file mode 100644 index 0000000..92acddd --- /dev/null +++ b/17_Day_Web_storages/17_day_starter/data/countries_data.js @@ -0,0 +1,2013 @@ +const countries = [ + { + name: 'Afghanistan', + capital: 'Kabul', + languages: ['Pashto', 'Uzbek', 'Turkmen'], + population: 27657145, + flag: 'https://restcountries.eu/data/afg.svg', + currency: 'Afghan afghani' + }, + { + name: 'Åland Islands', + capital: 'Mariehamn', + languages: ['Swedish'], + population: 28875, + flag: 'https://restcountries.eu/data/ala.svg', + currency: 'Euro' + }, + { + name: 'Albania', + capital: 'Tirana', + languages: ['Albanian'], + population: 2886026, + flag: 'https://restcountries.eu/data/alb.svg', + currency: 'Albanian lek' + }, + { + name: 'Algeria', + capital: 'Algiers', + languages: ['Arabic'], + population: 40400000, + flag: 'https://restcountries.eu/data/dza.svg', + currency: 'Algerian dinar' + }, + { + name: 'American Samoa', + capital: 'Pago Pago', + languages: ['English', 'Samoan'], + population: 57100, + flag: 'https://restcountries.eu/data/asm.svg', + currency: 'United State Dollar' + }, + { + name: 'Andorra', + capital: 'Andorra la Vella', + languages: ['Catalan'], + population: 78014, + flag: 'https://restcountries.eu/data/and.svg', + currency: 'Euro' + }, + { + name: 'Angola', + capital: 'Luanda', + languages: ['Portuguese'], + population: 25868000, + flag: 'https://restcountries.eu/data/ago.svg', + currency: 'Angolan kwanza' + }, + { + name: 'Anguilla', + capital: 'The Valley', + languages: ['English'], + population: 13452, + flag: 'https://restcountries.eu/data/aia.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Antarctica', + capital: '', + languages: ['English', 'Russian'], + population: 1000, + flag: 'https://restcountries.eu/data/ata.svg', + currency: 'Australian dollar' + }, + { + name: 'Antigua and Barbuda', + capital: "Saint John's", + languages: ['English'], + population: 86295, + flag: 'https://restcountries.eu/data/atg.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Argentina', + capital: 'Buenos Aires', + languages: ['Spanish', 'Guaraní'], + population: 43590400, + flag: 'https://restcountries.eu/data/arg.svg', + currency: 'Argentine peso' + }, + { + name: 'Armenia', + capital: 'Yerevan', + languages: ['Armenian', 'Russian'], + population: 2994400, + flag: 'https://restcountries.eu/data/arm.svg', + currency: 'Armenian dram' + }, + { + name: 'Aruba', + capital: 'Oranjestad', + languages: ['Dutch', '(Eastern) Punjabi'], + population: 107394, + flag: 'https://restcountries.eu/data/abw.svg', + currency: 'Aruban florin' + }, + { + name: 'Australia', + capital: 'Canberra', + languages: ['English'], + population: 24117360, + flag: 'https://restcountries.eu/data/aus.svg', + currency: 'Australian dollar' + }, + { + name: 'Austria', + capital: 'Vienna', + languages: ['German'], + population: 8725931, + flag: 'https://restcountries.eu/data/aut.svg', + currency: 'Euro' + }, + { + name: 'Azerbaijan', + capital: 'Baku', + languages: ['Azerbaijani'], + population: 9730500, + flag: 'https://restcountries.eu/data/aze.svg', + currency: 'Azerbaijani manat' + }, + { + name: 'Bahamas', + capital: 'Nassau', + languages: ['English'], + population: 378040, + flag: 'https://restcountries.eu/data/bhs.svg', + currency: 'Bahamian dollar' + }, + { + name: 'Bahrain', + capital: 'Manama', + languages: ['Arabic'], + population: 1404900, + flag: 'https://restcountries.eu/data/bhr.svg', + currency: 'Bahraini dinar' + }, + { + name: 'Bangladesh', + capital: 'Dhaka', + languages: ['Bengali'], + population: 161006790, + flag: 'https://restcountries.eu/data/bgd.svg', + currency: 'Bangladeshi taka' + }, + { + name: 'Barbados', + capital: 'Bridgetown', + languages: ['English'], + population: 285000, + flag: 'https://restcountries.eu/data/brb.svg', + currency: 'Barbadian dollar' + }, + { + name: 'Belarus', + capital: 'Minsk', + languages: ['Belarusian', 'Russian'], + population: 9498700, + flag: 'https://restcountries.eu/data/blr.svg', + currency: 'New Belarusian ruble' + }, + { + name: 'Belgium', + capital: 'Brussels', + languages: ['Dutch', 'French', 'German'], + population: 11319511, + flag: 'https://restcountries.eu/data/bel.svg', + currency: 'Euro' + }, + { + name: 'Belize', + capital: 'Belmopan', + languages: ['English', 'Spanish'], + population: 370300, + flag: 'https://restcountries.eu/data/blz.svg', + currency: 'Belize dollar' + }, + { + name: 'Benin', + capital: 'Porto-Novo', + languages: ['French'], + population: 10653654, + flag: 'https://restcountries.eu/data/ben.svg', + currency: 'West African CFA franc' + }, + { + name: 'Bermuda', + capital: 'Hamilton', + languages: ['English'], + population: 61954, + flag: 'https://restcountries.eu/data/bmu.svg', + currency: 'Bermudian dollar' + }, + { + name: 'Bhutan', + capital: 'Thimphu', + languages: ['Dzongkha'], + population: 775620, + flag: 'https://restcountries.eu/data/btn.svg', + currency: 'Bhutanese ngultrum' + }, + { + name: 'Bolivia (Plurinational State of)', + capital: 'Sucre', + languages: ['Spanish', 'Aymara', 'Quechua'], + population: 10985059, + flag: 'https://restcountries.eu/data/bol.svg', + currency: 'Bolivian boliviano' + }, + { + name: 'Bonaire, Sint Eustatius and Saba', + capital: 'Kralendijk', + languages: ['Dutch'], + population: 17408, + flag: 'https://restcountries.eu/data/bes.svg', + currency: 'United States dollar' + }, + { + name: 'Bosnia and Herzegovina', + capital: 'Sarajevo', + languages: ['Bosnian', 'Croatian', 'Serbian'], + population: 3531159, + flag: 'https://restcountries.eu/data/bih.svg', + currency: 'Bosnia and Herzegovina convertible mark' + }, + { + name: 'Botswana', + capital: 'Gaborone', + languages: ['English', 'Tswana'], + population: 2141206, + flag: 'https://restcountries.eu/data/bwa.svg', + currency: 'Botswana pula' + }, + { + name: 'Bouvet Island', + capital: '', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 0, + flag: 'https://restcountries.eu/data/bvt.svg', + currency: 'Norwegian krone' + }, + { + name: 'Brazil', + capital: 'Brasília', + languages: ['Portuguese'], + population: 206135893, + flag: 'https://restcountries.eu/data/bra.svg', + currency: 'Brazilian real' + }, + { + name: 'British Indian Ocean Territory', + capital: 'Diego Garcia', + languages: ['English'], + population: 3000, + flag: 'https://restcountries.eu/data/iot.svg', + currency: 'United States dollar' + }, + { + name: 'United States Minor Outlying Islands', + capital: '', + languages: ['English'], + population: 300, + flag: 'https://restcountries.eu/data/umi.svg', + currency: 'United States Dollar' + }, + { + name: 'Virgin Islands (British)', + capital: 'Road Town', + languages: ['English'], + population: 28514, + flag: 'https://restcountries.eu/data/vgb.svg', + currency: '[D]' + }, + { + name: 'Virgin Islands (U.S.)', + capital: 'Charlotte Amalie', + languages: ['English'], + population: 114743, + flag: 'https://restcountries.eu/data/vir.svg', + currency: 'United States dollar' + }, + { + name: 'Brunei Darussalam', + capital: 'Bandar Seri Begawan', + languages: ['Malay'], + population: 411900, + flag: 'https://restcountries.eu/data/brn.svg', + currency: 'Brunei dollar' + }, + { + name: 'Bulgaria', + capital: 'Sofia', + languages: ['Bulgarian'], + population: 7153784, + flag: 'https://restcountries.eu/data/bgr.svg', + currency: 'Bulgarian lev' + }, + { + name: 'Burkina Faso', + capital: 'Ouagadougou', + languages: ['French', 'Fula'], + population: 19034397, + flag: 'https://restcountries.eu/data/bfa.svg', + currency: 'West African CFA franc' + }, + { + name: 'Burundi', + capital: 'Bujumbura', + languages: ['French', 'Kirundi'], + population: 10114505, + flag: 'https://restcountries.eu/data/bdi.svg', + currency: 'Burundian franc' + }, + { + name: 'Cambodia', + capital: 'Phnom Penh', + languages: ['Khmer'], + population: 15626444, + flag: 'https://restcountries.eu/data/khm.svg', + currency: 'Cambodian riel' + }, + { + name: 'Cameroon', + capital: 'Yaoundé', + languages: ['English', 'French'], + population: 22709892, + flag: 'https://restcountries.eu/data/cmr.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Canada', + capital: 'Ottawa', + languages: ['English', 'French'], + population: 36155487, + flag: 'https://restcountries.eu/data/can.svg', + currency: 'Canadian dollar' + }, + { + name: 'Cabo Verde', + capital: 'Praia', + languages: ['Portuguese'], + population: 531239, + flag: 'https://restcountries.eu/data/cpv.svg', + currency: 'Cape Verdean escudo' + }, + { + name: 'Cayman Islands', + capital: 'George Town', + languages: ['English'], + population: 58238, + flag: 'https://restcountries.eu/data/cym.svg', + currency: 'Cayman Islands dollar' + }, + { + name: 'Central African Republic', + capital: 'Bangui', + languages: ['French', 'Sango'], + population: 4998000, + flag: 'https://restcountries.eu/data/caf.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chad', + capital: "N'Djamena", + languages: ['French', 'Arabic'], + population: 14497000, + flag: 'https://restcountries.eu/data/tcd.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chile', + capital: 'Santiago', + languages: ['Spanish'], + population: 18191900, + flag: 'https://restcountries.eu/data/chl.svg', + currency: 'Chilean peso' + }, + { + name: 'China', + capital: 'Beijing', + languages: ['Chinese'], + population: 1377422166, + flag: 'https://restcountries.eu/data/chn.svg', + currency: 'Chinese yuan' + }, + { + name: 'Christmas Island', + capital: 'Flying Fish Cove', + languages: ['English'], + population: 2072, + flag: 'https://restcountries.eu/data/cxr.svg', + currency: 'Australian dollar' + }, + { + name: 'Cocos (Keeling) Islands', + capital: 'West Island', + languages: ['English'], + population: 550, + flag: 'https://restcountries.eu/data/cck.svg', + currency: 'Australian dollar' + }, + { + name: 'Colombia', + capital: 'Bogotá', + languages: ['Spanish'], + population: 48759958, + flag: 'https://restcountries.eu/data/col.svg', + currency: 'Colombian peso' + }, + { + name: 'Comoros', + capital: 'Moroni', + languages: ['Arabic', 'French'], + population: 806153, + flag: 'https://restcountries.eu/data/com.svg', + currency: 'Comorian franc' + }, + { + name: 'Congo', + capital: 'Brazzaville', + languages: ['French', 'Lingala'], + population: 4741000, + flag: 'https://restcountries.eu/data/cog.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Congo (Democratic Republic of the)', + capital: 'Kinshasa', + languages: ['French', 'Lingala', 'Kongo', 'Swahili', 'Luba-Katanga'], + population: 85026000, + flag: 'https://restcountries.eu/data/cod.svg', + currency: 'Congolese franc' + }, + { + name: 'Cook Islands', + capital: 'Avarua', + languages: ['English'], + population: 18100, + flag: 'https://restcountries.eu/data/cok.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Costa Rica', + capital: 'San José', + languages: ['Spanish'], + population: 4890379, + flag: 'https://restcountries.eu/data/cri.svg', + currency: 'Costa Rican colón' + }, + { + name: 'Croatia', + capital: 'Zagreb', + languages: ['Croatian'], + population: 4190669, + flag: 'https://restcountries.eu/data/hrv.svg', + currency: 'Croatian kuna' + }, + { + name: 'Cuba', + capital: 'Havana', + languages: ['Spanish'], + population: 11239004, + flag: 'https://restcountries.eu/data/cub.svg', + currency: 'Cuban convertible peso' + }, + { + name: 'Curaçao', + capital: 'Willemstad', + languages: ['Dutch', '(Eastern) Punjabi', 'English'], + population: 154843, + flag: 'https://restcountries.eu/data/cuw.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Cyprus', + capital: 'Nicosia', + languages: ['Greek (modern)', 'Turkish', 'Armenian'], + population: 847000, + flag: 'https://restcountries.eu/data/cyp.svg', + currency: 'Euro' + }, + { + name: 'Czech Republic', + capital: 'Prague', + languages: ['Czech', 'Slovak'], + population: 10558524, + flag: 'https://restcountries.eu/data/cze.svg', + currency: 'Czech koruna' + }, + { + name: 'Denmark', + capital: 'Copenhagen', + languages: ['Danish'], + population: 5717014, + flag: 'https://restcountries.eu/data/dnk.svg', + currency: 'Danish krone' + }, + { + name: 'Djibouti', + capital: 'Djibouti', + languages: ['French', 'Arabic'], + population: 900000, + flag: 'https://restcountries.eu/data/dji.svg', + currency: 'Djiboutian franc' + }, + { + name: 'Dominica', + capital: 'Roseau', + languages: ['English'], + population: 71293, + flag: 'https://restcountries.eu/data/dma.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Dominican Republic', + capital: 'Santo Domingo', + languages: ['Spanish'], + population: 10075045, + flag: 'https://restcountries.eu/data/dom.svg', + currency: 'Dominican peso' + }, + { + name: 'Ecuador', + capital: 'Quito', + languages: ['Spanish'], + population: 16545799, + flag: 'https://restcountries.eu/data/ecu.svg', + currency: 'United States dollar' + }, + { + name: 'Egypt', + capital: 'Cairo', + languages: ['Arabic'], + population: 91290000, + flag: 'https://restcountries.eu/data/egy.svg', + currency: 'Egyptian pound' + }, + { + name: 'El Salvador', + capital: 'San Salvador', + languages: ['Spanish'], + population: 6520675, + flag: 'https://restcountries.eu/data/slv.svg', + currency: 'United States dollar' + }, + { + name: 'Equatorial Guinea', + capital: 'Malabo', + languages: ['Spanish', 'French'], + population: 1222442, + flag: 'https://restcountries.eu/data/gnq.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Eritrea', + capital: 'Asmara', + languages: ['Tigrinya', 'Arabic', 'English'], + population: 5352000, + flag: 'https://restcountries.eu/data/eri.svg', + currency: 'Eritrean nakfa' + }, + { + name: 'Estonia', + capital: 'Tallinn', + languages: ['Estonian'], + population: 1315944, + flag: 'https://restcountries.eu/data/est.svg', + currency: 'Euro' + }, + { + name: 'Ethiopia', + capital: 'Addis Ababa', + languages: ['Amharic'], + population: 92206005, + flag: 'https://restcountries.eu/data/eth.svg', + currency: 'Ethiopian birr' + }, + { + name: 'Falkland Islands (Malvinas)', + capital: 'Stanley', + languages: ['English'], + population: 2563, + flag: 'https://restcountries.eu/data/flk.svg', + currency: 'Falkland Islands pound' + }, + { + name: 'Faroe Islands', + capital: 'Tórshavn', + languages: ['Faroese'], + population: 49376, + flag: 'https://restcountries.eu/data/fro.svg', + currency: 'Danish krone' + }, + { + name: 'Fiji', + capital: 'Suva', + languages: ['English', 'Fijian', 'Hindi', 'Urdu'], + population: 867000, + flag: 'https://restcountries.eu/data/fji.svg', + currency: 'Fijian dollar' + }, + { + name: 'Finland', + capital: 'Helsinki', + languages: ['Finnish', 'Swedish'], + population: 5491817, + flag: 'https://restcountries.eu/data/fin.svg', + currency: 'Euro' + }, + { + name: 'France', + capital: 'Paris', + languages: ['French'], + population: 66710000, + flag: 'https://restcountries.eu/data/fra.svg', + currency: 'Euro' + }, + { + name: 'French Guiana', + capital: 'Cayenne', + languages: ['French'], + population: 254541, + flag: 'https://restcountries.eu/data/guf.svg', + currency: 'Euro' + }, + { + name: 'French Polynesia', + capital: 'Papeetē', + languages: ['French'], + population: 271800, + flag: 'https://restcountries.eu/data/pyf.svg', + currency: 'CFP franc' + }, + { + name: 'French Southern Territories', + capital: 'Port-aux-Français', + languages: ['French'], + population: 140, + flag: 'https://restcountries.eu/data/atf.svg', + currency: 'Euro' + }, + { + name: 'Gabon', + capital: 'Libreville', + languages: ['French'], + population: 1802278, + flag: 'https://restcountries.eu/data/gab.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Gambia', + capital: 'Banjul', + languages: ['English'], + population: 1882450, + flag: 'https://restcountries.eu/data/gmb.svg', + currency: 'Gambian dalasi' + }, + { + name: 'Georgia', + capital: 'Tbilisi', + languages: ['Georgian'], + population: 3720400, + flag: 'https://restcountries.eu/data/geo.svg', + currency: 'Georgian Lari' + }, + { + name: 'Germany', + capital: 'Berlin', + languages: ['German'], + population: 81770900, + flag: 'https://restcountries.eu/data/deu.svg', + currency: 'Euro' + }, + { + name: 'Ghana', + capital: 'Accra', + languages: ['English'], + population: 27670174, + flag: 'https://restcountries.eu/data/gha.svg', + currency: 'Ghanaian cedi' + }, + { + name: 'Gibraltar', + capital: 'Gibraltar', + languages: ['English'], + population: 33140, + flag: 'https://restcountries.eu/data/gib.svg', + currency: 'Gibraltar pound' + }, + { + name: 'Greece', + capital: 'Athens', + languages: ['Greek (modern)'], + population: 10858018, + flag: 'https://restcountries.eu/data/grc.svg', + currency: 'Euro' + }, + { + name: 'Greenland', + capital: 'Nuuk', + languages: ['Kalaallisut'], + population: 55847, + flag: 'https://restcountries.eu/data/grl.svg', + currency: 'Danish krone' + }, + { + name: 'Grenada', + capital: "St. George's", + languages: ['English'], + population: 103328, + flag: 'https://restcountries.eu/data/grd.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Guadeloupe', + capital: 'Basse-Terre', + languages: ['French'], + population: 400132, + flag: 'https://restcountries.eu/data/glp.svg', + currency: 'Euro' + }, + { + name: 'Guam', + capital: 'Hagåtña', + languages: ['English', 'Chamorro', 'Spanish'], + population: 184200, + flag: 'https://restcountries.eu/data/gum.svg', + currency: 'United States dollar' + }, + { + name: 'Guatemala', + capital: 'Guatemala City', + languages: ['Spanish'], + population: 16176133, + flag: 'https://restcountries.eu/data/gtm.svg', + currency: 'Guatemalan quetzal' + }, + { + name: 'Guernsey', + capital: 'St. Peter Port', + languages: ['English', 'French'], + population: 62999, + flag: 'https://restcountries.eu/data/ggy.svg', + currency: 'British pound' + }, + { + name: 'Guinea', + capital: 'Conakry', + languages: ['French', 'Fula'], + population: 12947000, + flag: 'https://restcountries.eu/data/gin.svg', + currency: 'Guinean franc' + }, + { + name: 'Guinea-Bissau', + capital: 'Bissau', + languages: ['Portuguese'], + population: 1547777, + flag: 'https://restcountries.eu/data/gnb.svg', + currency: 'West African CFA franc' + }, + { + name: 'Guyana', + capital: 'Georgetown', + languages: ['English'], + population: 746900, + flag: 'https://restcountries.eu/data/guy.svg', + currency: 'Guyanese dollar' + }, + { + name: 'Haiti', + capital: 'Port-au-Prince', + languages: ['French', 'Haitian'], + population: 11078033, + flag: 'https://restcountries.eu/data/hti.svg', + currency: 'Haitian gourde' + }, + { + name: 'Heard Island and McDonald Islands', + capital: '', + languages: ['English'], + population: 0, + flag: 'https://restcountries.eu/data/hmd.svg', + currency: 'Australian dollar' + }, + { + name: 'Holy See', + capital: 'Rome', + languages: ['Latin', 'Italian', 'French', 'German'], + population: 451, + flag: 'https://restcountries.eu/data/vat.svg', + currency: 'Euro' + }, + { + name: 'Honduras', + capital: 'Tegucigalpa', + languages: ['Spanish'], + population: 8576532, + flag: 'https://restcountries.eu/data/hnd.svg', + currency: 'Honduran lempira' + }, + { + name: 'Hong Kong', + capital: 'City of Victoria', + languages: ['English', 'Chinese'], + population: 7324300, + flag: 'https://restcountries.eu/data/hkg.svg', + currency: 'Hong Kong dollar' + }, + { + name: 'Hungary', + capital: 'Budapest', + languages: ['Hungarian'], + population: 9823000, + flag: 'https://restcountries.eu/data/hun.svg', + currency: 'Hungarian forint' + }, + { + name: 'Iceland', + capital: 'Reykjavík', + languages: ['Icelandic'], + population: 334300, + flag: 'https://restcountries.eu/data/isl.svg', + currency: 'Icelandic króna' + }, + { + name: 'India', + capital: 'New Delhi', + languages: ['Hindi', 'English'], + population: 1295210000, + flag: 'https://restcountries.eu/data/ind.svg', + currency: 'Indian rupee' + }, + { + name: 'Indonesia', + capital: 'Jakarta', + languages: ['Indonesian'], + population: 258705000, + flag: 'https://restcountries.eu/data/idn.svg', + currency: 'Indonesian rupiah' + }, + { + name: "Côte d'Ivoire", + capital: 'Yamoussoukro', + languages: ['French'], + population: 22671331, + flag: 'https://restcountries.eu/data/civ.svg', + currency: 'West African CFA franc' + }, + { + name: 'Iran (Islamic Republic of)', + capital: 'Tehran', + languages: ['Persian (Farsi)'], + population: 79369900, + flag: 'https://restcountries.eu/data/irn.svg', + currency: 'Iranian rial' + }, + { + name: 'Iraq', + capital: 'Baghdad', + languages: ['Arabic', 'Kurdish'], + population: 37883543, + flag: 'https://restcountries.eu/data/irq.svg', + currency: 'Iraqi dinar' + }, + { + name: 'Ireland', + capital: 'Dublin', + languages: ['Irish', 'English'], + population: 6378000, + flag: 'https://restcountries.eu/data/irl.svg', + currency: 'Euro' + }, + { + name: 'Isle of Man', + capital: 'Douglas', + languages: ['English', 'Manx'], + population: 84497, + flag: 'https://restcountries.eu/data/imn.svg', + currency: 'British pound' + }, + { + name: 'Israel', + capital: 'Jerusalem', + languages: ['Hebrew (modern)', 'Arabic'], + population: 8527400, + flag: 'https://restcountries.eu/data/isr.svg', + currency: 'Israeli new shekel' + }, + { + name: 'Italy', + capital: 'Rome', + languages: ['Italian'], + population: 60665551, + flag: 'https://restcountries.eu/data/ita.svg', + currency: 'Euro' + }, + { + name: 'Jamaica', + capital: 'Kingston', + languages: ['English'], + population: 2723246, + flag: 'https://restcountries.eu/data/jam.svg', + currency: 'Jamaican dollar' + }, + { + name: 'Japan', + capital: 'Tokyo', + languages: ['Japanese'], + population: 126960000, + flag: 'https://restcountries.eu/data/jpn.svg', + currency: 'Japanese yen' + }, + { + name: 'Jersey', + capital: 'Saint Helier', + languages: ['English', 'French'], + population: 100800, + flag: 'https://restcountries.eu/data/jey.svg', + currency: 'British pound' + }, + { + name: 'Jordan', + capital: 'Amman', + languages: ['Arabic'], + population: 9531712, + flag: 'https://restcountries.eu/data/jor.svg', + currency: 'Jordanian dinar' + }, + { + name: 'Kazakhstan', + capital: 'Astana', + languages: ['Kazakh', 'Russian'], + population: 17753200, + flag: 'https://restcountries.eu/data/kaz.svg', + currency: 'Kazakhstani tenge' + }, + { + name: 'Kenya', + capital: 'Nairobi', + languages: ['English', 'Swahili'], + population: 47251000, + flag: 'https://restcountries.eu/data/ken.svg', + currency: 'Kenyan shilling' + }, + { + name: 'Kiribati', + capital: 'South Tarawa', + languages: ['English'], + population: 113400, + flag: 'https://restcountries.eu/data/kir.svg', + currency: 'Australian dollar' + }, + { + name: 'Kuwait', + capital: 'Kuwait City', + languages: ['Arabic'], + population: 4183658, + flag: 'https://restcountries.eu/data/kwt.svg', + currency: 'Kuwaiti dinar' + }, + { + name: 'Kyrgyzstan', + capital: 'Bishkek', + languages: ['Kyrgyz', 'Russian'], + population: 6047800, + flag: 'https://restcountries.eu/data/kgz.svg', + currency: 'Kyrgyzstani som' + }, + { + name: "Lao People's Democratic Republic", + capital: 'Vientiane', + languages: ['Lao'], + population: 6492400, + flag: 'https://restcountries.eu/data/lao.svg', + currency: 'Lao kip' + }, + { + name: 'Latvia', + capital: 'Riga', + languages: ['Latvian'], + population: 1961600, + flag: 'https://restcountries.eu/data/lva.svg', + currency: 'Euro' + }, + { + name: 'Lebanon', + capital: 'Beirut', + languages: ['Arabic', 'French'], + population: 5988000, + flag: 'https://restcountries.eu/data/lbn.svg', + currency: 'Lebanese pound' + }, + { + name: 'Lesotho', + capital: 'Maseru', + languages: ['English', 'Southern Sotho'], + population: 1894194, + flag: 'https://restcountries.eu/data/lso.svg', + currency: 'Lesotho loti' + }, + { + name: 'Liberia', + capital: 'Monrovia', + languages: ['English'], + population: 4615000, + flag: 'https://restcountries.eu/data/lbr.svg', + currency: 'Liberian dollar' + }, + { + name: 'Libya', + capital: 'Tripoli', + languages: ['Arabic'], + population: 6385000, + flag: 'https://restcountries.eu/data/lby.svg', + currency: 'Libyan dinar' + }, + { + name: 'Liechtenstein', + capital: 'Vaduz', + languages: ['German'], + population: 37623, + flag: 'https://restcountries.eu/data/lie.svg', + currency: 'Swiss franc' + }, + { + name: 'Lithuania', + capital: 'Vilnius', + languages: ['Lithuanian'], + population: 2872294, + flag: 'https://restcountries.eu/data/ltu.svg', + currency: 'Euro' + }, + { + name: 'Luxembourg', + capital: 'Luxembourg', + languages: ['French', 'German', 'Luxembourgish'], + population: 576200, + flag: 'https://restcountries.eu/data/lux.svg', + currency: 'Euro' + }, + { + name: 'Macao', + capital: '', + languages: ['Chinese', 'Portuguese'], + population: 649100, + flag: 'https://restcountries.eu/data/mac.svg', + currency: 'Macanese pataca' + }, + { + name: 'Macedonia (the former Yugoslav Republic of)', + capital: 'Skopje', + languages: ['Macedonian'], + population: 2058539, + flag: 'https://restcountries.eu/data/mkd.svg', + currency: 'Macedonian denar' + }, + { + name: 'Madagascar', + capital: 'Antananarivo', + languages: ['French', 'Malagasy'], + population: 22434363, + flag: 'https://restcountries.eu/data/mdg.svg', + currency: 'Malagasy ariary' + }, + { + name: 'Malawi', + capital: 'Lilongwe', + languages: ['English', 'Chichewa'], + population: 16832910, + flag: 'https://restcountries.eu/data/mwi.svg', + currency: 'Malawian kwacha' + }, + { + name: 'Malaysia', + capital: 'Kuala Lumpur', + languages: ['Malaysian'], + population: 31405416, + flag: 'https://restcountries.eu/data/mys.svg', + currency: 'Malaysian ringgit' + }, + { + name: 'Maldives', + capital: 'Malé', + languages: ['Divehi'], + population: 344023, + flag: 'https://restcountries.eu/data/mdv.svg', + currency: 'Maldivian rufiyaa' + }, + { + name: 'Mali', + capital: 'Bamako', + languages: ['French'], + population: 18135000, + flag: 'https://restcountries.eu/data/mli.svg', + currency: 'West African CFA franc' + }, + { + name: 'Malta', + capital: 'Valletta', + languages: ['Maltese', 'English'], + population: 425384, + flag: 'https://restcountries.eu/data/mlt.svg', + currency: 'Euro' + }, + { + name: 'Marshall Islands', + capital: 'Majuro', + languages: ['English', 'Marshallese'], + population: 54880, + flag: 'https://restcountries.eu/data/mhl.svg', + currency: 'United States dollar' + }, + { + name: 'Martinique', + capital: 'Fort-de-France', + languages: ['French'], + population: 378243, + flag: 'https://restcountries.eu/data/mtq.svg', + currency: 'Euro' + }, + { + name: 'Mauritania', + capital: 'Nouakchott', + languages: ['Arabic'], + population: 3718678, + flag: 'https://restcountries.eu/data/mrt.svg', + currency: 'Mauritanian ouguiya' + }, + { + name: 'Mauritius', + capital: 'Port Louis', + languages: ['English'], + population: 1262879, + flag: 'https://restcountries.eu/data/mus.svg', + currency: 'Mauritian rupee' + }, + { + name: 'Mayotte', + capital: 'Mamoudzou', + languages: ['French'], + population: 226915, + flag: 'https://restcountries.eu/data/myt.svg', + currency: 'Euro' + }, + { + name: 'Mexico', + capital: 'Mexico City', + languages: ['Spanish'], + population: 122273473, + flag: 'https://restcountries.eu/data/mex.svg', + currency: 'Mexican peso' + }, + { + name: 'Micronesia (Federated States of)', + capital: 'Palikir', + languages: ['English'], + population: 102800, + flag: 'https://restcountries.eu/data/fsm.svg', + currency: '[D]' + }, + { + name: 'Moldova (Republic of)', + capital: 'Chișinău', + languages: ['Romanian'], + population: 3553100, + flag: 'https://restcountries.eu/data/mda.svg', + currency: 'Moldovan leu' + }, + { + name: 'Monaco', + capital: 'Monaco', + languages: ['French'], + population: 38400, + flag: 'https://restcountries.eu/data/mco.svg', + currency: 'Euro' + }, + { + name: 'Mongolia', + capital: 'Ulan Bator', + languages: ['Mongolian'], + population: 3093100, + flag: 'https://restcountries.eu/data/mng.svg', + currency: 'Mongolian tögrög' + }, + { + name: 'Montenegro', + capital: 'Podgorica', + languages: ['Serbian', 'Bosnian', 'Albanian', 'Croatian'], + population: 621810, + flag: 'https://restcountries.eu/data/mne.svg', + currency: 'Euro' + }, + { + name: 'Montserrat', + capital: 'Plymouth', + languages: ['English'], + population: 4922, + flag: 'https://restcountries.eu/data/msr.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Morocco', + capital: 'Rabat', + languages: ['Arabic'], + population: 33337529, + flag: 'https://restcountries.eu/data/mar.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Mozambique', + capital: 'Maputo', + languages: ['Portuguese'], + population: 26423700, + flag: 'https://restcountries.eu/data/moz.svg', + currency: 'Mozambican metical' + }, + { + name: 'Myanmar', + capital: 'Naypyidaw', + languages: ['Burmese'], + population: 51419420, + flag: 'https://restcountries.eu/data/mmr.svg', + currency: 'Burmese kyat' + }, + { + name: 'Namibia', + capital: 'Windhoek', + languages: ['English', 'Afrikaans'], + population: 2324388, + flag: 'https://restcountries.eu/data/nam.svg', + currency: 'Namibian dollar' + }, + { + name: 'Nauru', + capital: 'Yaren', + languages: ['English', 'Nauruan'], + population: 10084, + flag: 'https://restcountries.eu/data/nru.svg', + currency: 'Australian dollar' + }, + { + name: 'Nepal', + capital: 'Kathmandu', + languages: ['Nepali'], + population: 28431500, + flag: 'https://restcountries.eu/data/npl.svg', + currency: 'Nepalese rupee' + }, + { + name: 'Netherlands', + capital: 'Amsterdam', + languages: ['Dutch'], + population: 17019800, + flag: 'https://restcountries.eu/data/nld.svg', + currency: 'Euro' + }, + { + name: 'New Caledonia', + capital: 'Nouméa', + languages: ['French'], + population: 268767, + flag: 'https://restcountries.eu/data/ncl.svg', + currency: 'CFP franc' + }, + { + name: 'New Zealand', + capital: 'Wellington', + languages: ['English', 'Māori'], + population: 4697854, + flag: 'https://restcountries.eu/data/nzl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Nicaragua', + capital: 'Managua', + languages: ['Spanish'], + population: 6262703, + flag: 'https://restcountries.eu/data/nic.svg', + currency: 'Nicaraguan córdoba' + }, + { + name: 'Niger', + capital: 'Niamey', + languages: ['French'], + population: 20715000, + flag: 'https://restcountries.eu/data/ner.svg', + currency: 'West African CFA franc' + }, + { + name: 'Nigeria', + capital: 'Abuja', + languages: ['English'], + population: 186988000, + flag: 'https://restcountries.eu/data/nga.svg', + currency: 'Nigerian naira' + }, + { + name: 'Niue', + capital: 'Alofi', + languages: ['English'], + population: 1470, + flag: 'https://restcountries.eu/data/niu.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Norfolk Island', + capital: 'Kingston', + languages: ['English'], + population: 2302, + flag: 'https://restcountries.eu/data/nfk.svg', + currency: 'Australian dollar' + }, + { + name: "Korea (Democratic People's Republic of)", + capital: 'Pyongyang', + languages: ['Korean'], + population: 25281000, + flag: 'https://restcountries.eu/data/prk.svg', + currency: 'North Korean won' + }, + { + name: 'Northern Mariana Islands', + capital: 'Saipan', + languages: ['English', 'Chamorro'], + population: 56940, + flag: 'https://restcountries.eu/data/mnp.svg', + currency: 'United States dollar' + }, + { + name: 'Norway', + capital: 'Oslo', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 5223256, + flag: 'https://restcountries.eu/data/nor.svg', + currency: 'Norwegian krone' + }, + { + name: 'Oman', + capital: 'Muscat', + languages: ['Arabic'], + population: 4420133, + flag: 'https://restcountries.eu/data/omn.svg', + currency: 'Omani rial' + }, + { + name: 'Pakistan', + capital: 'Islamabad', + languages: ['English', 'Urdu'], + population: 194125062, + flag: 'https://restcountries.eu/data/pak.svg', + currency: 'Pakistani rupee' + }, + { + name: 'Palau', + capital: 'Ngerulmud', + languages: ['English'], + population: 17950, + flag: 'https://restcountries.eu/data/plw.svg', + currency: '[E]' + }, + { + name: 'Palestine, State of', + capital: 'Ramallah', + languages: ['Arabic'], + population: 4682467, + flag: 'https://restcountries.eu/data/pse.svg', + currency: 'Israeli new sheqel' + }, + { + name: 'Panama', + capital: 'Panama City', + languages: ['Spanish'], + population: 3814672, + flag: 'https://restcountries.eu/data/pan.svg', + currency: 'Panamanian balboa' + }, + { + name: 'Papua New Guinea', + capital: 'Port Moresby', + languages: ['English'], + population: 8083700, + flag: 'https://restcountries.eu/data/png.svg', + currency: 'Papua New Guinean kina' + }, + { + name: 'Paraguay', + capital: 'Asunción', + languages: ['Spanish', 'Guaraní'], + population: 6854536, + flag: 'https://restcountries.eu/data/pry.svg', + currency: 'Paraguayan guaraní' + }, + { + name: 'Peru', + capital: 'Lima', + languages: ['Spanish'], + population: 31488700, + flag: 'https://restcountries.eu/data/per.svg', + currency: 'Peruvian sol' + }, + { + name: 'Philippines', + capital: 'Manila', + languages: ['English'], + population: 103279800, + flag: 'https://restcountries.eu/data/phl.svg', + currency: 'Philippine peso' + }, + { + name: 'Pitcairn', + capital: 'Adamstown', + languages: ['English'], + population: 56, + flag: 'https://restcountries.eu/data/pcn.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Poland', + capital: 'Warsaw', + languages: ['Polish'], + population: 38437239, + flag: 'https://restcountries.eu/data/pol.svg', + currency: 'Polish złoty' + }, + { + name: 'Portugal', + capital: 'Lisbon', + languages: ['Portuguese'], + population: 10374822, + flag: 'https://restcountries.eu/data/prt.svg', + currency: 'Euro' + }, + { + name: 'Puerto Rico', + capital: 'San Juan', + languages: ['Spanish', 'English'], + population: 3474182, + flag: 'https://restcountries.eu/data/pri.svg', + currency: 'United States dollar' + }, + { + name: 'Qatar', + capital: 'Doha', + languages: ['Arabic'], + population: 2587564, + flag: 'https://restcountries.eu/data/qat.svg', + currency: 'Qatari riyal' + }, + { + name: 'Republic of Kosovo', + capital: 'Pristina', + languages: ['Albanian', 'Serbian'], + population: 1733842, + flag: 'https://restcountries.eu/data/kos.svg', + currency: 'Euro' + }, + { + name: 'Réunion', + capital: 'Saint-Denis', + languages: ['French'], + population: 840974, + flag: 'https://restcountries.eu/data/reu.svg', + currency: 'Euro' + }, + { + name: 'Romania', + capital: 'Bucharest', + languages: ['Romanian'], + population: 19861408, + flag: 'https://restcountries.eu/data/rou.svg', + currency: 'Romanian leu' + }, + { + name: 'Russian Federation', + capital: 'Moscow', + languages: ['Russian'], + population: 146599183, + flag: 'https://restcountries.eu/data/rus.svg', + currency: 'Russian ruble' + }, + { + name: 'Rwanda', + capital: 'Kigali', + languages: ['Kinyarwanda', 'English', 'French'], + population: 11553188, + flag: 'https://restcountries.eu/data/rwa.svg', + currency: 'Rwandan franc' + }, + { + name: 'Saint Barthélemy', + capital: 'Gustavia', + languages: ['French'], + population: 9417, + flag: 'https://restcountries.eu/data/blm.svg', + currency: 'Euro' + }, + { + name: 'Saint Helena, Ascension and Tristan da Cunha', + capital: 'Jamestown', + languages: ['English'], + population: 4255, + flag: 'https://restcountries.eu/data/shn.svg', + currency: 'Saint Helena pound' + }, + { + name: 'Saint Kitts and Nevis', + capital: 'Basseterre', + languages: ['English'], + population: 46204, + flag: 'https://restcountries.eu/data/kna.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Lucia', + capital: 'Castries', + languages: ['English'], + population: 186000, + flag: 'https://restcountries.eu/data/lca.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Martin (French part)', + capital: 'Marigot', + languages: ['English', 'French', 'Dutch'], + population: 36979, + flag: 'https://restcountries.eu/data/maf.svg', + currency: 'Euro' + }, + { + name: 'Saint Pierre and Miquelon', + capital: 'Saint-Pierre', + languages: ['French'], + population: 6069, + flag: 'https://restcountries.eu/data/spm.svg', + currency: 'Euro' + }, + { + name: 'Saint Vincent and the Grenadines', + capital: 'Kingstown', + languages: ['English'], + population: 109991, + flag: 'https://restcountries.eu/data/vct.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Samoa', + capital: 'Apia', + languages: ['Samoan', 'English'], + population: 194899, + flag: 'https://restcountries.eu/data/wsm.svg', + currency: 'Samoan tālā' + }, + { + name: 'San Marino', + capital: 'City of San Marino', + languages: ['Italian'], + population: 33005, + flag: 'https://restcountries.eu/data/smr.svg', + currency: 'Euro' + }, + { + name: 'Sao Tome and Principe', + capital: 'São Tomé', + languages: ['Portuguese'], + population: 187356, + flag: 'https://restcountries.eu/data/stp.svg', + currency: 'São Tomé and Príncipe dobra' + }, + { + name: 'Saudi Arabia', + capital: 'Riyadh', + languages: ['Arabic'], + population: 32248200, + flag: 'https://restcountries.eu/data/sau.svg', + currency: 'Saudi riyal' + }, + { + name: 'Senegal', + capital: 'Dakar', + languages: ['French'], + population: 14799859, + flag: 'https://restcountries.eu/data/sen.svg', + currency: 'West African CFA franc' + }, + { + name: 'Serbia', + capital: 'Belgrade', + languages: ['Serbian'], + population: 7076372, + flag: 'https://restcountries.eu/data/srb.svg', + currency: 'Serbian dinar' + }, + { + name: 'Seychelles', + capital: 'Victoria', + languages: ['French', 'English'], + population: 91400, + flag: 'https://restcountries.eu/data/syc.svg', + currency: 'Seychellois rupee' + }, + { + name: 'Sierra Leone', + capital: 'Freetown', + languages: ['English'], + population: 7075641, + flag: 'https://restcountries.eu/data/sle.svg', + currency: 'Sierra Leonean leone' + }, + { + name: 'Singapore', + capital: 'Singapore', + languages: ['English', 'Malay', 'Tamil', 'Chinese'], + population: 5535000, + flag: 'https://restcountries.eu/data/sgp.svg', + currency: 'Brunei dollar' + }, + { + name: 'Sint Maarten (Dutch part)', + capital: 'Philipsburg', + languages: ['Dutch', 'English'], + population: 38247, + flag: 'https://restcountries.eu/data/sxm.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Slovakia', + capital: 'Bratislava', + languages: ['Slovak'], + population: 5426252, + flag: 'https://restcountries.eu/data/svk.svg', + currency: 'Euro' + }, + { + name: 'Slovenia', + capital: 'Ljubljana', + languages: ['Slovene'], + population: 2064188, + flag: 'https://restcountries.eu/data/svn.svg', + currency: 'Euro' + }, + { + name: 'Solomon Islands', + capital: 'Honiara', + languages: ['English'], + population: 642000, + flag: 'https://restcountries.eu/data/slb.svg', + currency: 'Solomon Islands dollar' + }, + { + name: 'Somalia', + capital: 'Mogadishu', + languages: ['Somali', 'Arabic'], + population: 11079000, + flag: 'https://restcountries.eu/data/som.svg', + currency: 'Somali shilling' + }, + { + name: 'South Africa', + capital: 'Pretoria', + languages: [ + 'Afrikaans', + 'English', + 'Southern Ndebele', + 'Southern Sotho', + 'Swati', + 'Tswana', + 'Tsonga', + 'Venda', + 'Xhosa', + 'Zulu' + ], + population: 55653654, + flag: 'https://restcountries.eu/data/zaf.svg', + currency: 'South African rand' + }, + { + name: 'South Georgia and the South Sandwich Islands', + capital: 'King Edward Point', + languages: ['English'], + population: 30, + flag: 'https://restcountries.eu/data/sgs.svg', + currency: 'British pound' + }, + { + name: 'Korea (Republic of)', + capital: 'Seoul', + languages: ['Korean'], + population: 50801405, + flag: 'https://restcountries.eu/data/kor.svg', + currency: 'South Korean won' + }, + { + name: 'South Sudan', + capital: 'Juba', + languages: ['English'], + population: 12131000, + flag: 'https://restcountries.eu/data/ssd.svg', + currency: 'South Sudanese pound' + }, + { + name: 'Spain', + capital: 'Madrid', + languages: ['Spanish'], + population: 46438422, + flag: 'https://restcountries.eu/data/esp.svg', + currency: 'Euro' + }, + { + name: 'Sri Lanka', + capital: 'Colombo', + languages: ['Sinhalese', 'Tamil'], + population: 20966000, + flag: 'https://restcountries.eu/data/lka.svg', + currency: 'Sri Lankan rupee' + }, + { + name: 'Sudan', + capital: 'Khartoum', + languages: ['Arabic', 'English'], + population: 39598700, + flag: 'https://restcountries.eu/data/sdn.svg', + currency: 'Sudanese pound' + }, + { + name: 'Suriname', + capital: 'Paramaribo', + languages: ['Dutch'], + population: 541638, + flag: 'https://restcountries.eu/data/sur.svg', + currency: 'Surinamese dollar' + }, + { + name: 'Svalbard and Jan Mayen', + capital: 'Longyearbyen', + languages: ['Norwegian'], + population: 2562, + flag: 'https://restcountries.eu/data/sjm.svg', + currency: 'Norwegian krone' + }, + { + name: 'Swaziland', + capital: 'Lobamba', + languages: ['English', 'Swati'], + population: 1132657, + flag: 'https://restcountries.eu/data/swz.svg', + currency: 'Swazi lilangeni' + }, + { + name: 'Sweden', + capital: 'Stockholm', + languages: ['Swedish'], + population: 9894888, + flag: 'https://restcountries.eu/data/swe.svg', + currency: 'Swedish krona' + }, + { + name: 'Switzerland', + capital: 'Bern', + languages: ['German', 'French', 'Italian'], + population: 8341600, + flag: 'https://restcountries.eu/data/che.svg', + currency: 'Swiss franc' + }, + { + name: 'Syrian Arab Republic', + capital: 'Damascus', + languages: ['Arabic'], + population: 18564000, + flag: 'https://restcountries.eu/data/syr.svg', + currency: 'Syrian pound' + }, + { + name: 'Taiwan', + capital: 'Taipei', + languages: ['Chinese'], + population: 23503349, + flag: 'https://restcountries.eu/data/twn.svg', + currency: 'New Taiwan dollar' + }, + { + name: 'Tajikistan', + capital: 'Dushanbe', + languages: ['Tajik', 'Russian'], + population: 8593600, + flag: 'https://restcountries.eu/data/tjk.svg', + currency: 'Tajikistani somoni' + }, + { + name: 'Tanzania, United Republic of', + capital: 'Dodoma', + languages: ['Swahili', 'English'], + population: 55155000, + flag: 'https://restcountries.eu/data/tza.svg', + currency: 'Tanzanian shilling' + }, + { + name: 'Thailand', + capital: 'Bangkok', + languages: ['Thai'], + population: 65327652, + flag: 'https://restcountries.eu/data/tha.svg', + currency: 'Thai baht' + }, + { + name: 'Timor-Leste', + capital: 'Dili', + languages: ['Portuguese'], + population: 1167242, + flag: 'https://restcountries.eu/data/tls.svg', + currency: 'United States dollar' + }, + { + name: 'Togo', + capital: 'Lomé', + languages: ['French'], + population: 7143000, + flag: 'https://restcountries.eu/data/tgo.svg', + currency: 'West African CFA franc' + }, + { + name: 'Tokelau', + capital: 'Fakaofo', + languages: ['English'], + population: 1411, + flag: 'https://restcountries.eu/data/tkl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Tonga', + capital: "Nuku'alofa", + languages: ['English', 'Tonga (Tonga Islands)'], + population: 103252, + flag: 'https://restcountries.eu/data/ton.svg', + currency: 'Tongan paʻanga' + }, + { + name: 'Trinidad and Tobago', + capital: 'Port of Spain', + languages: ['English'], + population: 1349667, + flag: 'https://restcountries.eu/data/tto.svg', + currency: 'Trinidad and Tobago dollar' + }, + { + name: 'Tunisia', + capital: 'Tunis', + languages: ['Arabic'], + population: 11154400, + flag: 'https://restcountries.eu/data/tun.svg', + currency: 'Tunisian dinar' + }, + { + name: 'Turkey', + capital: 'Ankara', + languages: ['Turkish'], + population: 78741053, + flag: 'https://restcountries.eu/data/tur.svg', + currency: 'Turkish lira' + }, + { + name: 'Turkmenistan', + capital: 'Ashgabat', + languages: ['Turkmen', 'Russian'], + population: 4751120, + flag: 'https://restcountries.eu/data/tkm.svg', + currency: 'Turkmenistan manat' + }, + { + name: 'Turks and Caicos Islands', + capital: 'Cockburn Town', + languages: ['English'], + population: 31458, + flag: 'https://restcountries.eu/data/tca.svg', + currency: 'United States dollar' + }, + { + name: 'Tuvalu', + capital: 'Funafuti', + languages: ['English'], + population: 10640, + flag: 'https://restcountries.eu/data/tuv.svg', + currency: 'Australian dollar' + }, + { + name: 'Uganda', + capital: 'Kampala', + languages: ['English', 'Swahili'], + population: 33860700, + flag: 'https://restcountries.eu/data/uga.svg', + currency: 'Ugandan shilling' + }, + { + name: 'Ukraine', + capital: 'Kiev', + languages: ['Ukrainian'], + population: 42692393, + flag: 'https://restcountries.eu/data/ukr.svg', + currency: 'Ukrainian hryvnia' + }, + { + name: 'United Arab Emirates', + capital: 'Abu Dhabi', + languages: ['Arabic'], + population: 9856000, + flag: 'https://restcountries.eu/data/are.svg', + currency: 'United Arab Emirates dirham' + }, + { + name: 'United Kingdom of Great Britain and Northern Ireland', + capital: 'London', + languages: ['English'], + population: 65110000, + flag: 'https://restcountries.eu/data/gbr.svg', + currency: 'British pound' + }, + { + name: 'United States of America', + capital: 'Washington, D.C.', + languages: ['English'], + population: 323947000, + flag: 'https://restcountries.eu/data/usa.svg', + currency: 'United States dollar' + }, + { + name: 'Uruguay', + capital: 'Montevideo', + languages: ['Spanish'], + population: 3480222, + flag: 'https://restcountries.eu/data/ury.svg', + currency: 'Uruguayan peso' + }, + { + name: 'Uzbekistan', + capital: 'Tashkent', + languages: ['Uzbek', 'Russian'], + population: 31576400, + flag: 'https://restcountries.eu/data/uzb.svg', + currency: "Uzbekistani so'm" + }, + { + name: 'Vanuatu', + capital: 'Port Vila', + languages: ['Bislama', 'English', 'French'], + population: 277500, + flag: 'https://restcountries.eu/data/vut.svg', + currency: 'Vanuatu vatu' + }, + { + name: 'Venezuela (Bolivarian Republic of)', + capital: 'Caracas', + languages: ['Spanish'], + population: 31028700, + flag: 'https://restcountries.eu/data/ven.svg', + currency: 'Venezuelan bolívar' + }, + { + name: 'Viet Nam', + capital: 'Hanoi', + languages: ['Vietnamese'], + population: 92700000, + flag: 'https://restcountries.eu/data/vnm.svg', + currency: 'Vietnamese đồng' + }, + { + name: 'Wallis and Futuna', + capital: 'Mata-Utu', + languages: ['French'], + population: 11750, + flag: 'https://restcountries.eu/data/wlf.svg', + currency: 'CFP franc' + }, + { + name: 'Western Sahara', + capital: 'El Aaiún', + languages: ['Spanish'], + population: 510713, + flag: 'https://restcountries.eu/data/esh.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Yemen', + capital: "Sana'a", + languages: ['Arabic'], + population: 27478000, + flag: 'https://restcountries.eu/data/yem.svg', + currency: 'Yemeni rial' + }, + { + name: 'Zambia', + capital: 'Lusaka', + languages: ['English'], + population: 15933883, + flag: 'https://restcountries.eu/data/zmb.svg', + currency: 'Zambian kwacha' + }, + { + name: 'Zimbabwe', + capital: 'Harare', + languages: ['English', 'Shona', 'Northern Ndebele'], + population: 14240168, + flag: 'https://restcountries.eu/data/zwe.svg', + currency: 'Botswana pula' + } +] diff --git a/17_Day_Web_storages/17_day_starter/index.html b/17_Day_Web_storages/17_day_starter/index.html new file mode 100644 index 0000000..e76eeef --- /dev/null +++ b/17_Day_Web_storages/17_day_starter/index.html @@ -0,0 +1,16 @@ + + + + + 30DaysOfJavaScript:17 Day + + + +

30DaysOfJavaScript:17 Day

+

Web Storage

+ + + + + + \ No newline at end of file diff --git a/17_Day_Web_storages/17_day_starter/scripts/main.js b/17_Day_Web_storages/17_day_starter/scripts/main.js new file mode 100644 index 0000000..e69de29 diff --git a/17_Day_Web_storages/17_day_web_storages.md b/17_Day_Web_storages/17_day_web_storages.md new file mode 100644 index 0000000..f10d14d --- /dev/null +++ b/17_Day_Web_storages/17_day_web_storages.md @@ -0,0 +1,233 @@ +
+

30 Days Of JavaScript: Web Storages

+ + + + + Twitter Follow + + +Author: +Asabeneh Yetayeh
+ January, 2020 +
+ +
+ +[<< Day 16](../16_Day_JSON/16_day_json.md) | [Day 18 >>](../18_Day_Promises/18_day_promises.md) + +![Thirty Days Of JavaScript](../images/banners/day_1_17.png) + +- [Day 17](#day-17) + - [HTML5 Web Storage](#html5-web-storage) + - [sessionStorage](#sessionstorage) + - [localStorage](#localstorage) + - [Use case of Web Storages](#use-case-of-web-storages) + - [HTML5 Web Storage Objects](#html5-web-storage-objects) + - [Setting item to the localStorage](#setting-item-to-the-localstorage) + - [Getting item from localStorage](#getting-item-from-localstorage) + - [Clearing the localStorage](#clearing-the-localstorage) + - [Exercises](#exercises) + - [Exercises: Level 1](#exercises-level-1) + - [Exercises: Level 2](#exercises-level-2) + - [Exercises: Level 3](#exercises-level-3) + +# Day 17 + +## HTML5 Web Storage + +Web Storage(sessionStorage and localStorage) is a new HTML5 API offering important benefits over traditional cookies. Before HTML5, application data had to be stored in cookies, included in every server request. Web storage is more secure, and large amounts of data can be stored locally, without affecting website performance. The data storage limit of cookies in many web browsers is about 4 KB per cookie. We Storages can store far larger data (at least 5MB) and never transferred to the server. All sites from the same or one origin can store and access the same data. + +The data being stored can be accessed using JavaScript, which gives you the ability to leverage client-side scripting to do many things that have traditionally involved server-side programming and relational databases. The are are two Web Storage objects: + +- sessionStorage +- localStorage + +localStorage is similar to sessionStorage, except that while data stored in localStorage has no expiration time, data stored in sessionStorage gets cleared when the page session ends — that is, when the page is closed. + +It should be noted that data stored in either localStorage or sessionStorage is specific to the protocol of the page. + +The keys and the values are always strings (note that, as with objects, integer keys will be automatically converted to strings). + +![web_storage](../images/web_storage.png) + +### sessionStorage + +sessionStorage is only available within the browser tab or window session. It’s designed to store data in a single web page session. That means if the window is closed the session data will be removed. Since sessionStorage and localStorage has similar methods, we will focus only on localStorage. + +### localStorage + +The HTML5 localStorage is the para of the web storage API which is used to store data on the browser with no expiration data. The data will be available on the browser even after the browser is closed. localStorage is kept even between browser sessions. This means data is still available when the browser is closed and reopened, and also instantly between tabs and windows. + +Web Storage data is, in both cases, not available between different browsers. For example, storage objects created in Firefox cannot be accessed in Internet Explorer, exactly like cookies. There are five methods to work on local storage: +_setItem(), getItem(), removeItem(), clear(), key()_ + +### Use case of Web Storages + +Some use case of Web Storages are + +- store data temporarily +- saving products that the user places in his shopping cart +- data can be made available between page requests, multiple browser tabs, and also between browser sessions using localStorage +- can be used offline completely using localStorage +- Web Storage can be a great performance win when some static data is stored on the client to minimize the number of subsequent requests. Even images can be stored in strings using Base64 encoding. +- can be used for user authentication method + +For the examples mentioned above, it makes sense to use localStorage. You may be wondering, then, when we should use sessionStorage. + +In cases, we want to to get rid of the data as soon as the window is closed. Or, perhaps, if we do not want the application to interfere with the same application that’s open in another window. These scenarios are served best with sessionStorage. + +Now, let use how use make use of these Web Storage APIs. + +## HTML5 Web Storage Objects + +HTML web storage provides two objects for storing data on the client: + +- window.localStorage - stores data with no expiration date +- window.sessionStorage - stores data for one session (data is lost when the browser tab is closed)Most modern browsers support Web Storage, however it is good to check browser support for localStorage and sessionStorage. Let us see the available methods for the Web Storage objects. + +Web Storage objects: + +- _localStorage_ - to display the localStorage object +- _localStorage.clear()_ - to remove everything in the local storage +- _localStorage.setItem()_ - to storage data in the localStorage. It takes a key and a value parameters. +- _localStorage.getItem()_ - to display data stored in the localStorage. It takes a key as a parameter. +- _localStorage.removeItem()_ - to remove stored item form a localStorage. It takes key as a parameter. +- _localStorage.key()_ - to display a data stored in a localStorage. It takes index as a parameter. + +![local_storage](../images/local_storage.png) + +### Setting item to the localStorage + +When we set data to be stored in a localStorage, it will be stored as a string. If we are storing an array or an object, we should stringify it first to keep the format unless otherwise we lose the array structure or the object structure of the original data. + +We store data in the localStorage using the _localStorage.setItem_ method. + +```js +//syntax +localStorage.setItem('key', 'value') +``` + +- Storing string in a localStorage + +```js +localStorage.setItem('firstName', 'Asabeneh') // since the value is string we do not stringify it +console.log(localStorage) +``` + +```sh +Storage {firstName: 'Asabeneh', length: 1} +``` + +- Storing number in a local storage + +```js +localStorage.setItem('age', 200) +console.log(localStorage) +``` + +```sh + Storage {age: '200', firstName: 'Asabeneh', length: 2} +``` + +- Storing an array in a localStorage. If we are storing an array, an object or object array, we should stringify the object first. See the example below. + +```js +const skills = ['HTML', 'CSS', 'JS', 'React'] +//Skills array has to be stringified first to keep the format. +const skillsJSON = JSON.stringify(skills, undefined, 4) +localStorage.setItem('skills', skillsJSON) +console.log(localStorage) +``` + +```sh +Storage {age: '200', firstName: 'Asabeneh', skills: 'HTML,CSS,JS,React', length: 3} +``` + +```js +let skills = [ + { tech: 'HTML', level: 10 }, + { tech: 'CSS', level: 9 }, + { tech: 'JS', level: 8 }, + { tech: 'React', level: 9 }, + { tech: 'Redux', level: 10 }, + { tech: 'Node', level: 8 }, + { tech: 'MongoDB', level: 8 } +] + +let skillJSON = JSON.stringify(skills) +localStorage.setItem('skills', skillJSON) +``` + +- Storing an object in a localStorage. Before we storage objects to a localStorage, the object has to be stringified. + +```js +const user = { + firstName: 'Asabeneh', + age: 250, + skills: ['HTML', 'CSS', 'JS', 'React'] +} + +const userText = JSON.stringify(user, undefined, 4) +localStorage.setItem('user', userText) +``` + +### Getting item from localStorage + +We get data from the local storage using _localStorage.getItem()_ method. + +```js +//syntax +localStorage.getItem('key') +``` + +```js +let firstName = localStorage.getItem('firstName') +let age = localStorage.getItem('age') +let skills = localStorage.getItem('skills') +console.log(firstName, age, skills) +``` + +```sh + 'Asabeneh', '200', '['HTML','CSS','JS','React']' +``` + +As you can see the skill is in a string format. Let us use JSON.parse() to parse it to normal array. + +```js +let skills = localStorage.getItem('skills') +let skillsObj = JSON.parse(skills, undefined, 4) +console.log(skillsObj) +``` + +```sh +['HTML','CSS','JS','React'] +``` + +### Clearing the localStorage + +The clear method, will clear everything stored in the local storage + +```js +localStorage.clear() +``` + +🌕 You are determined .Now, you knew a Web Storages and you knew how to store small data on client browsers. You are 17 steps a head to your way to greatness. Now do some exercises for your brain and for your muscle. + +## Exercises + +### Exercises: Level 1 + +1. Store you first name, last name, age, country, city in your browser localStorage. + +### Exercises: Level 2 + +1. Create a student object. The student object will have first name, last name, age, skills, country, enrolled keys and values for the keys. Store the student object in your browser localStorage. + +### Exercises: Level 3 + +1. Create an object called personAccount. It has firstname, lastname, incomes, expenses properties and it has totalIncome, totalExpense, accountInfo,addIncome, addExpense and accountBalance methods. Incomes is a set of incomes and its description and expenses is also a set of expenses and its description. + +🎉 CONGRATULATIONS ! 🎉 + +[<< Day 16](../16_Day_JSON/16_day_json.md) | [Day 18 >>](../18_Day_Promises/18_day_promises.md) diff --git a/18_Day_Promises/18_day_promises.md b/18_Day_Promises/18_day_promises.md new file mode 100644 index 0000000..6d7be2a --- /dev/null +++ b/18_Day_Promises/18_day_promises.md @@ -0,0 +1,272 @@ +
+

30 Days Of JavaScript: Promises

+ + + + + Twitter Follow + + +Author: +Asabeneh Yetayeh
+ January, 2020 +
+ +
+ +[<< Day 17](../17_Day_Web_storages/17_day_web_storages.md) | [Day 19>>](../19_Day_Closures/19_day_closures.md) + +![Thirty Days Of JavaScript](../images/banners/day_1_18.png) + +- [Day 18](#day-18) + - [Promise](#promise) + - [Callbacks](#callbacks) + - [Promise constructor](#promise-constructor) + - [Fetch API](#fetch-api) + - [Async and Await](#async-and-await) + - [Exercises](#exercises) + - [Exercises: Level 1](#exercises-level-1) + - [Exercises: Level 2](#exercises-level-2) + - [Exercises: Level 3](#exercises-level-3) + +# Day 18 + +## Promise + +We human give or receive a promise to do some activity at some point in time. If we keep the promise we make others happy but if we do not keep the promise, it may lead discontentment. Promise in JavaScript has something in common with the above examples. + +A Promise is a way to handle asynchronous operations in JavaScript. It allows handlers with an asynchronous action's eventual success value or failure reason. This lets asynchronous methods return values like synchronous methods: instead of immediately returning the final value, the asynchronous method returns a promise to supply the value at some point in the future. + +A Promise is in one of these states: + +- pending: initial state, neither fulfilled nor rejected. +- fulfilled: meaning that the operation completed successfully. +- rejected: meaning that the operation failed. + +A pending promise can either be fulfilled with a value, or rejected with a reason (error). When either of these options happens, the associated handlers queued up by a promise's then method are called. (If the promise has already been fulfilled or rejected when a corresponding handler is attached, the handler will be called, so there is no race condition between an asynchronous operation completing and its handlers being attached.) + +As the Promise.prototype.then() and Promise.prototype.catch() methods return promises, they can be chained. + +## Callbacks + +To understand promise very well let us understand callback first. Let's see the following callbacks. From the following code blocks you will notice, the difference between callback and promises. + +- call back +Let us see a callback function which can take two parameters. The first parameter is err and the second is result. If the err parameter is false, there will not be error other wise it will return an error. + +In this case the err has a value and it will return the err block. + +```js +//Callback +const doSomething = callback => { + setTimeout(() => { + const skills = ['HTML', 'CSS', 'JS'] + callback('It did not go well', skills) + }, 2000) +} + +const callback = (err, result) => { + if (err) { + return console.log(err) + } + return console.log(result) +} + +doSomething(callback) + +``` + +```sh +// after 2 seconds it will print +It did not go well +``` + +In this case the err is false and it will return the else block which is the result. + +```js +const doSomething = callback => { + setTimeout(() => { + const skills = ['HTML', 'CSS', 'JS'] + callback(false, skills) + }, 2000) +} + +doSomething((err, result) => { + if (err) { + return console.log(err) + } + return console.log(result) +}) +``` + +```sh +// after 2 seconds it will print the skills +["HTML", "CSS", "JS"] +``` + +### Promise constructor + +We can create a promise using the Promise constructor. We can create a new promise using the key word new followed by the word Promise and followed by a parenthesis. Inside the parenthesis it it takes a callback function. The promise callback function has two parameters which are the *resolve* and *reject* functions. + +```js +// syntax +const promise = new Promise((resolve, reject) => { + resolve('success') + reject('failure') +}) +``` + +```js +// Promise +const doPromise = new Promise((resolve, reject) => { + setTimeout(() => { + const skills = ['HTML', 'CSS', 'JS'] + if (skills.length > 0) { + resolve(skills) + } else { + reject('Something wrong has happened') + } + }, 2000) +}) + +doPromise + .then(result => { + console.log(result) + }) + .catch(error => console.log(error)) + ``` + + ```sh + ["HTML", "CSS", "JS"] + ``` + + The above promise has been settled with resolve. + Let us another example when the promise is settled with reject. + +```js +// Promise +const doPromise = new Promise((resolve, reject) => { + setTimeout(() => { + const skills = ['HTML', 'CSS', 'JS'] + if (skills.indexOf('Node') !== -1) { + resolve('fullstack developer') + } else { + reject('Something wrong has happened') + } + }, 2000) +}) + +doPromise + .then(result => { + console.log(result) + }) + .catch(error => console.log(error)) + ``` + + ```sh + Something wrong has happened + ``` + +## Fetch API + +The Fetch API provides an interface for fetching resources (including across the network). It will seem familiar to anyone who has used XMLHttpRequest, but the new API provides a more powerful and flexible feature set. In this challenge we will use fetch to request url and APIS. In addition to that let us see demonstrate use case of promises in accessing network resources using the fetch API. + +```js +const url = 'https://restcountries.eu/rest/v2/all' // countries api +fetch(url) + .then(response => response.json()) // accessing the API data as JSON + .then(data => { // getting the data + console.log(data) + }) + .catch(error => console.log(error)) // handling error if something wrong happens +``` + +## Async and Await + +Async and await is an elegant way to handle promises. It is easy to understand and it clean to write. + +```js +const square = async function (n) { + return n * n +} + +square(2) +``` + +```sh +Promise {: 4} +``` + +The word *async* in front of a function means that function will return a promise. The above square function instead of a value it returned a promise. + +How do we access the value from the promise? To access the value from the promise, we will use the keyword *await*. + +```js +const square = async function (n) { + return n * n +} +const value = await square(2) +``` + +```sh +4 +``` + +Now, as you can see from the above example writing async in front of a function create a promise and to get the value from a promise we use await. Async and await go together, one can not exist without the other. + +Let us fetch API data using both promise method and async and await method. + +- promise + +```js +const url = 'https://restcountries.eu/rest/v2/all' +fetch(url) + .then(response => response.json()) + .then(data => { + console.log(data) + }) + .catch(error => console.log(error)) +``` + +- async and await + +```js +const fetchData = async () => { + try { + const response = await fetch(url) + const countries = await response.json() + console.log(countries) + } catch (err) { + console.log(err) + } +} +console.log('===== async and await') +fetchData() +``` + +🌕 You are real and you kept your promise and your reached to day 18. Keep your promise and settle the challenge with resolve. You are 18 steps a head to your way to greatness. Now do some exercises for your brain and for your muscle. + +## Exercises + +```js +const countriesAPI = 'https://restcountries.eu/rest/v2/all' +const catsAPI = 'https://api.thecatapi.com/v1/breeds' +``` + +### Exercises: Level 1 + +1. Read the countries API using fetch and print the name of country, capital, languages, population and area. + +### Exercises: Level 2 + +1. Print out all the cat names in to catNames variable. + +### Exercises: Level 3 + +1. Read the cats api and find the average weight of cat in metric unit. +2. Read the countries api and find out the 10 largest countries +3. Read the countries api and count total number of languages in the world used as officials. + +🎉 CONGRATULATIONS ! 🎉 + +[<< Day 17](../17_Day_Web_storages/17_day_web_storages.md) | [Day 19>>](../19_Day_Closures/19_day_closures.md) diff --git a/18_Day_Promises/18_day_starter/data/countries_data.js b/18_Day_Promises/18_day_starter/data/countries_data.js new file mode 100644 index 0000000..92acddd --- /dev/null +++ b/18_Day_Promises/18_day_starter/data/countries_data.js @@ -0,0 +1,2013 @@ +const countries = [ + { + name: 'Afghanistan', + capital: 'Kabul', + languages: ['Pashto', 'Uzbek', 'Turkmen'], + population: 27657145, + flag: 'https://restcountries.eu/data/afg.svg', + currency: 'Afghan afghani' + }, + { + name: 'Åland Islands', + capital: 'Mariehamn', + languages: ['Swedish'], + population: 28875, + flag: 'https://restcountries.eu/data/ala.svg', + currency: 'Euro' + }, + { + name: 'Albania', + capital: 'Tirana', + languages: ['Albanian'], + population: 2886026, + flag: 'https://restcountries.eu/data/alb.svg', + currency: 'Albanian lek' + }, + { + name: 'Algeria', + capital: 'Algiers', + languages: ['Arabic'], + population: 40400000, + flag: 'https://restcountries.eu/data/dza.svg', + currency: 'Algerian dinar' + }, + { + name: 'American Samoa', + capital: 'Pago Pago', + languages: ['English', 'Samoan'], + population: 57100, + flag: 'https://restcountries.eu/data/asm.svg', + currency: 'United State Dollar' + }, + { + name: 'Andorra', + capital: 'Andorra la Vella', + languages: ['Catalan'], + population: 78014, + flag: 'https://restcountries.eu/data/and.svg', + currency: 'Euro' + }, + { + name: 'Angola', + capital: 'Luanda', + languages: ['Portuguese'], + population: 25868000, + flag: 'https://restcountries.eu/data/ago.svg', + currency: 'Angolan kwanza' + }, + { + name: 'Anguilla', + capital: 'The Valley', + languages: ['English'], + population: 13452, + flag: 'https://restcountries.eu/data/aia.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Antarctica', + capital: '', + languages: ['English', 'Russian'], + population: 1000, + flag: 'https://restcountries.eu/data/ata.svg', + currency: 'Australian dollar' + }, + { + name: 'Antigua and Barbuda', + capital: "Saint John's", + languages: ['English'], + population: 86295, + flag: 'https://restcountries.eu/data/atg.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Argentina', + capital: 'Buenos Aires', + languages: ['Spanish', 'Guaraní'], + population: 43590400, + flag: 'https://restcountries.eu/data/arg.svg', + currency: 'Argentine peso' + }, + { + name: 'Armenia', + capital: 'Yerevan', + languages: ['Armenian', 'Russian'], + population: 2994400, + flag: 'https://restcountries.eu/data/arm.svg', + currency: 'Armenian dram' + }, + { + name: 'Aruba', + capital: 'Oranjestad', + languages: ['Dutch', '(Eastern) Punjabi'], + population: 107394, + flag: 'https://restcountries.eu/data/abw.svg', + currency: 'Aruban florin' + }, + { + name: 'Australia', + capital: 'Canberra', + languages: ['English'], + population: 24117360, + flag: 'https://restcountries.eu/data/aus.svg', + currency: 'Australian dollar' + }, + { + name: 'Austria', + capital: 'Vienna', + languages: ['German'], + population: 8725931, + flag: 'https://restcountries.eu/data/aut.svg', + currency: 'Euro' + }, + { + name: 'Azerbaijan', + capital: 'Baku', + languages: ['Azerbaijani'], + population: 9730500, + flag: 'https://restcountries.eu/data/aze.svg', + currency: 'Azerbaijani manat' + }, + { + name: 'Bahamas', + capital: 'Nassau', + languages: ['English'], + population: 378040, + flag: 'https://restcountries.eu/data/bhs.svg', + currency: 'Bahamian dollar' + }, + { + name: 'Bahrain', + capital: 'Manama', + languages: ['Arabic'], + population: 1404900, + flag: 'https://restcountries.eu/data/bhr.svg', + currency: 'Bahraini dinar' + }, + { + name: 'Bangladesh', + capital: 'Dhaka', + languages: ['Bengali'], + population: 161006790, + flag: 'https://restcountries.eu/data/bgd.svg', + currency: 'Bangladeshi taka' + }, + { + name: 'Barbados', + capital: 'Bridgetown', + languages: ['English'], + population: 285000, + flag: 'https://restcountries.eu/data/brb.svg', + currency: 'Barbadian dollar' + }, + { + name: 'Belarus', + capital: 'Minsk', + languages: ['Belarusian', 'Russian'], + population: 9498700, + flag: 'https://restcountries.eu/data/blr.svg', + currency: 'New Belarusian ruble' + }, + { + name: 'Belgium', + capital: 'Brussels', + languages: ['Dutch', 'French', 'German'], + population: 11319511, + flag: 'https://restcountries.eu/data/bel.svg', + currency: 'Euro' + }, + { + name: 'Belize', + capital: 'Belmopan', + languages: ['English', 'Spanish'], + population: 370300, + flag: 'https://restcountries.eu/data/blz.svg', + currency: 'Belize dollar' + }, + { + name: 'Benin', + capital: 'Porto-Novo', + languages: ['French'], + population: 10653654, + flag: 'https://restcountries.eu/data/ben.svg', + currency: 'West African CFA franc' + }, + { + name: 'Bermuda', + capital: 'Hamilton', + languages: ['English'], + population: 61954, + flag: 'https://restcountries.eu/data/bmu.svg', + currency: 'Bermudian dollar' + }, + { + name: 'Bhutan', + capital: 'Thimphu', + languages: ['Dzongkha'], + population: 775620, + flag: 'https://restcountries.eu/data/btn.svg', + currency: 'Bhutanese ngultrum' + }, + { + name: 'Bolivia (Plurinational State of)', + capital: 'Sucre', + languages: ['Spanish', 'Aymara', 'Quechua'], + population: 10985059, + flag: 'https://restcountries.eu/data/bol.svg', + currency: 'Bolivian boliviano' + }, + { + name: 'Bonaire, Sint Eustatius and Saba', + capital: 'Kralendijk', + languages: ['Dutch'], + population: 17408, + flag: 'https://restcountries.eu/data/bes.svg', + currency: 'United States dollar' + }, + { + name: 'Bosnia and Herzegovina', + capital: 'Sarajevo', + languages: ['Bosnian', 'Croatian', 'Serbian'], + population: 3531159, + flag: 'https://restcountries.eu/data/bih.svg', + currency: 'Bosnia and Herzegovina convertible mark' + }, + { + name: 'Botswana', + capital: 'Gaborone', + languages: ['English', 'Tswana'], + population: 2141206, + flag: 'https://restcountries.eu/data/bwa.svg', + currency: 'Botswana pula' + }, + { + name: 'Bouvet Island', + capital: '', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 0, + flag: 'https://restcountries.eu/data/bvt.svg', + currency: 'Norwegian krone' + }, + { + name: 'Brazil', + capital: 'Brasília', + languages: ['Portuguese'], + population: 206135893, + flag: 'https://restcountries.eu/data/bra.svg', + currency: 'Brazilian real' + }, + { + name: 'British Indian Ocean Territory', + capital: 'Diego Garcia', + languages: ['English'], + population: 3000, + flag: 'https://restcountries.eu/data/iot.svg', + currency: 'United States dollar' + }, + { + name: 'United States Minor Outlying Islands', + capital: '', + languages: ['English'], + population: 300, + flag: 'https://restcountries.eu/data/umi.svg', + currency: 'United States Dollar' + }, + { + name: 'Virgin Islands (British)', + capital: 'Road Town', + languages: ['English'], + population: 28514, + flag: 'https://restcountries.eu/data/vgb.svg', + currency: '[D]' + }, + { + name: 'Virgin Islands (U.S.)', + capital: 'Charlotte Amalie', + languages: ['English'], + population: 114743, + flag: 'https://restcountries.eu/data/vir.svg', + currency: 'United States dollar' + }, + { + name: 'Brunei Darussalam', + capital: 'Bandar Seri Begawan', + languages: ['Malay'], + population: 411900, + flag: 'https://restcountries.eu/data/brn.svg', + currency: 'Brunei dollar' + }, + { + name: 'Bulgaria', + capital: 'Sofia', + languages: ['Bulgarian'], + population: 7153784, + flag: 'https://restcountries.eu/data/bgr.svg', + currency: 'Bulgarian lev' + }, + { + name: 'Burkina Faso', + capital: 'Ouagadougou', + languages: ['French', 'Fula'], + population: 19034397, + flag: 'https://restcountries.eu/data/bfa.svg', + currency: 'West African CFA franc' + }, + { + name: 'Burundi', + capital: 'Bujumbura', + languages: ['French', 'Kirundi'], + population: 10114505, + flag: 'https://restcountries.eu/data/bdi.svg', + currency: 'Burundian franc' + }, + { + name: 'Cambodia', + capital: 'Phnom Penh', + languages: ['Khmer'], + population: 15626444, + flag: 'https://restcountries.eu/data/khm.svg', + currency: 'Cambodian riel' + }, + { + name: 'Cameroon', + capital: 'Yaoundé', + languages: ['English', 'French'], + population: 22709892, + flag: 'https://restcountries.eu/data/cmr.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Canada', + capital: 'Ottawa', + languages: ['English', 'French'], + population: 36155487, + flag: 'https://restcountries.eu/data/can.svg', + currency: 'Canadian dollar' + }, + { + name: 'Cabo Verde', + capital: 'Praia', + languages: ['Portuguese'], + population: 531239, + flag: 'https://restcountries.eu/data/cpv.svg', + currency: 'Cape Verdean escudo' + }, + { + name: 'Cayman Islands', + capital: 'George Town', + languages: ['English'], + population: 58238, + flag: 'https://restcountries.eu/data/cym.svg', + currency: 'Cayman Islands dollar' + }, + { + name: 'Central African Republic', + capital: 'Bangui', + languages: ['French', 'Sango'], + population: 4998000, + flag: 'https://restcountries.eu/data/caf.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chad', + capital: "N'Djamena", + languages: ['French', 'Arabic'], + population: 14497000, + flag: 'https://restcountries.eu/data/tcd.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chile', + capital: 'Santiago', + languages: ['Spanish'], + population: 18191900, + flag: 'https://restcountries.eu/data/chl.svg', + currency: 'Chilean peso' + }, + { + name: 'China', + capital: 'Beijing', + languages: ['Chinese'], + population: 1377422166, + flag: 'https://restcountries.eu/data/chn.svg', + currency: 'Chinese yuan' + }, + { + name: 'Christmas Island', + capital: 'Flying Fish Cove', + languages: ['English'], + population: 2072, + flag: 'https://restcountries.eu/data/cxr.svg', + currency: 'Australian dollar' + }, + { + name: 'Cocos (Keeling) Islands', + capital: 'West Island', + languages: ['English'], + population: 550, + flag: 'https://restcountries.eu/data/cck.svg', + currency: 'Australian dollar' + }, + { + name: 'Colombia', + capital: 'Bogotá', + languages: ['Spanish'], + population: 48759958, + flag: 'https://restcountries.eu/data/col.svg', + currency: 'Colombian peso' + }, + { + name: 'Comoros', + capital: 'Moroni', + languages: ['Arabic', 'French'], + population: 806153, + flag: 'https://restcountries.eu/data/com.svg', + currency: 'Comorian franc' + }, + { + name: 'Congo', + capital: 'Brazzaville', + languages: ['French', 'Lingala'], + population: 4741000, + flag: 'https://restcountries.eu/data/cog.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Congo (Democratic Republic of the)', + capital: 'Kinshasa', + languages: ['French', 'Lingala', 'Kongo', 'Swahili', 'Luba-Katanga'], + population: 85026000, + flag: 'https://restcountries.eu/data/cod.svg', + currency: 'Congolese franc' + }, + { + name: 'Cook Islands', + capital: 'Avarua', + languages: ['English'], + population: 18100, + flag: 'https://restcountries.eu/data/cok.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Costa Rica', + capital: 'San José', + languages: ['Spanish'], + population: 4890379, + flag: 'https://restcountries.eu/data/cri.svg', + currency: 'Costa Rican colón' + }, + { + name: 'Croatia', + capital: 'Zagreb', + languages: ['Croatian'], + population: 4190669, + flag: 'https://restcountries.eu/data/hrv.svg', + currency: 'Croatian kuna' + }, + { + name: 'Cuba', + capital: 'Havana', + languages: ['Spanish'], + population: 11239004, + flag: 'https://restcountries.eu/data/cub.svg', + currency: 'Cuban convertible peso' + }, + { + name: 'Curaçao', + capital: 'Willemstad', + languages: ['Dutch', '(Eastern) Punjabi', 'English'], + population: 154843, + flag: 'https://restcountries.eu/data/cuw.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Cyprus', + capital: 'Nicosia', + languages: ['Greek (modern)', 'Turkish', 'Armenian'], + population: 847000, + flag: 'https://restcountries.eu/data/cyp.svg', + currency: 'Euro' + }, + { + name: 'Czech Republic', + capital: 'Prague', + languages: ['Czech', 'Slovak'], + population: 10558524, + flag: 'https://restcountries.eu/data/cze.svg', + currency: 'Czech koruna' + }, + { + name: 'Denmark', + capital: 'Copenhagen', + languages: ['Danish'], + population: 5717014, + flag: 'https://restcountries.eu/data/dnk.svg', + currency: 'Danish krone' + }, + { + name: 'Djibouti', + capital: 'Djibouti', + languages: ['French', 'Arabic'], + population: 900000, + flag: 'https://restcountries.eu/data/dji.svg', + currency: 'Djiboutian franc' + }, + { + name: 'Dominica', + capital: 'Roseau', + languages: ['English'], + population: 71293, + flag: 'https://restcountries.eu/data/dma.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Dominican Republic', + capital: 'Santo Domingo', + languages: ['Spanish'], + population: 10075045, + flag: 'https://restcountries.eu/data/dom.svg', + currency: 'Dominican peso' + }, + { + name: 'Ecuador', + capital: 'Quito', + languages: ['Spanish'], + population: 16545799, + flag: 'https://restcountries.eu/data/ecu.svg', + currency: 'United States dollar' + }, + { + name: 'Egypt', + capital: 'Cairo', + languages: ['Arabic'], + population: 91290000, + flag: 'https://restcountries.eu/data/egy.svg', + currency: 'Egyptian pound' + }, + { + name: 'El Salvador', + capital: 'San Salvador', + languages: ['Spanish'], + population: 6520675, + flag: 'https://restcountries.eu/data/slv.svg', + currency: 'United States dollar' + }, + { + name: 'Equatorial Guinea', + capital: 'Malabo', + languages: ['Spanish', 'French'], + population: 1222442, + flag: 'https://restcountries.eu/data/gnq.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Eritrea', + capital: 'Asmara', + languages: ['Tigrinya', 'Arabic', 'English'], + population: 5352000, + flag: 'https://restcountries.eu/data/eri.svg', + currency: 'Eritrean nakfa' + }, + { + name: 'Estonia', + capital: 'Tallinn', + languages: ['Estonian'], + population: 1315944, + flag: 'https://restcountries.eu/data/est.svg', + currency: 'Euro' + }, + { + name: 'Ethiopia', + capital: 'Addis Ababa', + languages: ['Amharic'], + population: 92206005, + flag: 'https://restcountries.eu/data/eth.svg', + currency: 'Ethiopian birr' + }, + { + name: 'Falkland Islands (Malvinas)', + capital: 'Stanley', + languages: ['English'], + population: 2563, + flag: 'https://restcountries.eu/data/flk.svg', + currency: 'Falkland Islands pound' + }, + { + name: 'Faroe Islands', + capital: 'Tórshavn', + languages: ['Faroese'], + population: 49376, + flag: 'https://restcountries.eu/data/fro.svg', + currency: 'Danish krone' + }, + { + name: 'Fiji', + capital: 'Suva', + languages: ['English', 'Fijian', 'Hindi', 'Urdu'], + population: 867000, + flag: 'https://restcountries.eu/data/fji.svg', + currency: 'Fijian dollar' + }, + { + name: 'Finland', + capital: 'Helsinki', + languages: ['Finnish', 'Swedish'], + population: 5491817, + flag: 'https://restcountries.eu/data/fin.svg', + currency: 'Euro' + }, + { + name: 'France', + capital: 'Paris', + languages: ['French'], + population: 66710000, + flag: 'https://restcountries.eu/data/fra.svg', + currency: 'Euro' + }, + { + name: 'French Guiana', + capital: 'Cayenne', + languages: ['French'], + population: 254541, + flag: 'https://restcountries.eu/data/guf.svg', + currency: 'Euro' + }, + { + name: 'French Polynesia', + capital: 'Papeetē', + languages: ['French'], + population: 271800, + flag: 'https://restcountries.eu/data/pyf.svg', + currency: 'CFP franc' + }, + { + name: 'French Southern Territories', + capital: 'Port-aux-Français', + languages: ['French'], + population: 140, + flag: 'https://restcountries.eu/data/atf.svg', + currency: 'Euro' + }, + { + name: 'Gabon', + capital: 'Libreville', + languages: ['French'], + population: 1802278, + flag: 'https://restcountries.eu/data/gab.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Gambia', + capital: 'Banjul', + languages: ['English'], + population: 1882450, + flag: 'https://restcountries.eu/data/gmb.svg', + currency: 'Gambian dalasi' + }, + { + name: 'Georgia', + capital: 'Tbilisi', + languages: ['Georgian'], + population: 3720400, + flag: 'https://restcountries.eu/data/geo.svg', + currency: 'Georgian Lari' + }, + { + name: 'Germany', + capital: 'Berlin', + languages: ['German'], + population: 81770900, + flag: 'https://restcountries.eu/data/deu.svg', + currency: 'Euro' + }, + { + name: 'Ghana', + capital: 'Accra', + languages: ['English'], + population: 27670174, + flag: 'https://restcountries.eu/data/gha.svg', + currency: 'Ghanaian cedi' + }, + { + name: 'Gibraltar', + capital: 'Gibraltar', + languages: ['English'], + population: 33140, + flag: 'https://restcountries.eu/data/gib.svg', + currency: 'Gibraltar pound' + }, + { + name: 'Greece', + capital: 'Athens', + languages: ['Greek (modern)'], + population: 10858018, + flag: 'https://restcountries.eu/data/grc.svg', + currency: 'Euro' + }, + { + name: 'Greenland', + capital: 'Nuuk', + languages: ['Kalaallisut'], + population: 55847, + flag: 'https://restcountries.eu/data/grl.svg', + currency: 'Danish krone' + }, + { + name: 'Grenada', + capital: "St. George's", + languages: ['English'], + population: 103328, + flag: 'https://restcountries.eu/data/grd.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Guadeloupe', + capital: 'Basse-Terre', + languages: ['French'], + population: 400132, + flag: 'https://restcountries.eu/data/glp.svg', + currency: 'Euro' + }, + { + name: 'Guam', + capital: 'Hagåtña', + languages: ['English', 'Chamorro', 'Spanish'], + population: 184200, + flag: 'https://restcountries.eu/data/gum.svg', + currency: 'United States dollar' + }, + { + name: 'Guatemala', + capital: 'Guatemala City', + languages: ['Spanish'], + population: 16176133, + flag: 'https://restcountries.eu/data/gtm.svg', + currency: 'Guatemalan quetzal' + }, + { + name: 'Guernsey', + capital: 'St. Peter Port', + languages: ['English', 'French'], + population: 62999, + flag: 'https://restcountries.eu/data/ggy.svg', + currency: 'British pound' + }, + { + name: 'Guinea', + capital: 'Conakry', + languages: ['French', 'Fula'], + population: 12947000, + flag: 'https://restcountries.eu/data/gin.svg', + currency: 'Guinean franc' + }, + { + name: 'Guinea-Bissau', + capital: 'Bissau', + languages: ['Portuguese'], + population: 1547777, + flag: 'https://restcountries.eu/data/gnb.svg', + currency: 'West African CFA franc' + }, + { + name: 'Guyana', + capital: 'Georgetown', + languages: ['English'], + population: 746900, + flag: 'https://restcountries.eu/data/guy.svg', + currency: 'Guyanese dollar' + }, + { + name: 'Haiti', + capital: 'Port-au-Prince', + languages: ['French', 'Haitian'], + population: 11078033, + flag: 'https://restcountries.eu/data/hti.svg', + currency: 'Haitian gourde' + }, + { + name: 'Heard Island and McDonald Islands', + capital: '', + languages: ['English'], + population: 0, + flag: 'https://restcountries.eu/data/hmd.svg', + currency: 'Australian dollar' + }, + { + name: 'Holy See', + capital: 'Rome', + languages: ['Latin', 'Italian', 'French', 'German'], + population: 451, + flag: 'https://restcountries.eu/data/vat.svg', + currency: 'Euro' + }, + { + name: 'Honduras', + capital: 'Tegucigalpa', + languages: ['Spanish'], + population: 8576532, + flag: 'https://restcountries.eu/data/hnd.svg', + currency: 'Honduran lempira' + }, + { + name: 'Hong Kong', + capital: 'City of Victoria', + languages: ['English', 'Chinese'], + population: 7324300, + flag: 'https://restcountries.eu/data/hkg.svg', + currency: 'Hong Kong dollar' + }, + { + name: 'Hungary', + capital: 'Budapest', + languages: ['Hungarian'], + population: 9823000, + flag: 'https://restcountries.eu/data/hun.svg', + currency: 'Hungarian forint' + }, + { + name: 'Iceland', + capital: 'Reykjavík', + languages: ['Icelandic'], + population: 334300, + flag: 'https://restcountries.eu/data/isl.svg', + currency: 'Icelandic króna' + }, + { + name: 'India', + capital: 'New Delhi', + languages: ['Hindi', 'English'], + population: 1295210000, + flag: 'https://restcountries.eu/data/ind.svg', + currency: 'Indian rupee' + }, + { + name: 'Indonesia', + capital: 'Jakarta', + languages: ['Indonesian'], + population: 258705000, + flag: 'https://restcountries.eu/data/idn.svg', + currency: 'Indonesian rupiah' + }, + { + name: "Côte d'Ivoire", + capital: 'Yamoussoukro', + languages: ['French'], + population: 22671331, + flag: 'https://restcountries.eu/data/civ.svg', + currency: 'West African CFA franc' + }, + { + name: 'Iran (Islamic Republic of)', + capital: 'Tehran', + languages: ['Persian (Farsi)'], + population: 79369900, + flag: 'https://restcountries.eu/data/irn.svg', + currency: 'Iranian rial' + }, + { + name: 'Iraq', + capital: 'Baghdad', + languages: ['Arabic', 'Kurdish'], + population: 37883543, + flag: 'https://restcountries.eu/data/irq.svg', + currency: 'Iraqi dinar' + }, + { + name: 'Ireland', + capital: 'Dublin', + languages: ['Irish', 'English'], + population: 6378000, + flag: 'https://restcountries.eu/data/irl.svg', + currency: 'Euro' + }, + { + name: 'Isle of Man', + capital: 'Douglas', + languages: ['English', 'Manx'], + population: 84497, + flag: 'https://restcountries.eu/data/imn.svg', + currency: 'British pound' + }, + { + name: 'Israel', + capital: 'Jerusalem', + languages: ['Hebrew (modern)', 'Arabic'], + population: 8527400, + flag: 'https://restcountries.eu/data/isr.svg', + currency: 'Israeli new shekel' + }, + { + name: 'Italy', + capital: 'Rome', + languages: ['Italian'], + population: 60665551, + flag: 'https://restcountries.eu/data/ita.svg', + currency: 'Euro' + }, + { + name: 'Jamaica', + capital: 'Kingston', + languages: ['English'], + population: 2723246, + flag: 'https://restcountries.eu/data/jam.svg', + currency: 'Jamaican dollar' + }, + { + name: 'Japan', + capital: 'Tokyo', + languages: ['Japanese'], + population: 126960000, + flag: 'https://restcountries.eu/data/jpn.svg', + currency: 'Japanese yen' + }, + { + name: 'Jersey', + capital: 'Saint Helier', + languages: ['English', 'French'], + population: 100800, + flag: 'https://restcountries.eu/data/jey.svg', + currency: 'British pound' + }, + { + name: 'Jordan', + capital: 'Amman', + languages: ['Arabic'], + population: 9531712, + flag: 'https://restcountries.eu/data/jor.svg', + currency: 'Jordanian dinar' + }, + { + name: 'Kazakhstan', + capital: 'Astana', + languages: ['Kazakh', 'Russian'], + population: 17753200, + flag: 'https://restcountries.eu/data/kaz.svg', + currency: 'Kazakhstani tenge' + }, + { + name: 'Kenya', + capital: 'Nairobi', + languages: ['English', 'Swahili'], + population: 47251000, + flag: 'https://restcountries.eu/data/ken.svg', + currency: 'Kenyan shilling' + }, + { + name: 'Kiribati', + capital: 'South Tarawa', + languages: ['English'], + population: 113400, + flag: 'https://restcountries.eu/data/kir.svg', + currency: 'Australian dollar' + }, + { + name: 'Kuwait', + capital: 'Kuwait City', + languages: ['Arabic'], + population: 4183658, + flag: 'https://restcountries.eu/data/kwt.svg', + currency: 'Kuwaiti dinar' + }, + { + name: 'Kyrgyzstan', + capital: 'Bishkek', + languages: ['Kyrgyz', 'Russian'], + population: 6047800, + flag: 'https://restcountries.eu/data/kgz.svg', + currency: 'Kyrgyzstani som' + }, + { + name: "Lao People's Democratic Republic", + capital: 'Vientiane', + languages: ['Lao'], + population: 6492400, + flag: 'https://restcountries.eu/data/lao.svg', + currency: 'Lao kip' + }, + { + name: 'Latvia', + capital: 'Riga', + languages: ['Latvian'], + population: 1961600, + flag: 'https://restcountries.eu/data/lva.svg', + currency: 'Euro' + }, + { + name: 'Lebanon', + capital: 'Beirut', + languages: ['Arabic', 'French'], + population: 5988000, + flag: 'https://restcountries.eu/data/lbn.svg', + currency: 'Lebanese pound' + }, + { + name: 'Lesotho', + capital: 'Maseru', + languages: ['English', 'Southern Sotho'], + population: 1894194, + flag: 'https://restcountries.eu/data/lso.svg', + currency: 'Lesotho loti' + }, + { + name: 'Liberia', + capital: 'Monrovia', + languages: ['English'], + population: 4615000, + flag: 'https://restcountries.eu/data/lbr.svg', + currency: 'Liberian dollar' + }, + { + name: 'Libya', + capital: 'Tripoli', + languages: ['Arabic'], + population: 6385000, + flag: 'https://restcountries.eu/data/lby.svg', + currency: 'Libyan dinar' + }, + { + name: 'Liechtenstein', + capital: 'Vaduz', + languages: ['German'], + population: 37623, + flag: 'https://restcountries.eu/data/lie.svg', + currency: 'Swiss franc' + }, + { + name: 'Lithuania', + capital: 'Vilnius', + languages: ['Lithuanian'], + population: 2872294, + flag: 'https://restcountries.eu/data/ltu.svg', + currency: 'Euro' + }, + { + name: 'Luxembourg', + capital: 'Luxembourg', + languages: ['French', 'German', 'Luxembourgish'], + population: 576200, + flag: 'https://restcountries.eu/data/lux.svg', + currency: 'Euro' + }, + { + name: 'Macao', + capital: '', + languages: ['Chinese', 'Portuguese'], + population: 649100, + flag: 'https://restcountries.eu/data/mac.svg', + currency: 'Macanese pataca' + }, + { + name: 'Macedonia (the former Yugoslav Republic of)', + capital: 'Skopje', + languages: ['Macedonian'], + population: 2058539, + flag: 'https://restcountries.eu/data/mkd.svg', + currency: 'Macedonian denar' + }, + { + name: 'Madagascar', + capital: 'Antananarivo', + languages: ['French', 'Malagasy'], + population: 22434363, + flag: 'https://restcountries.eu/data/mdg.svg', + currency: 'Malagasy ariary' + }, + { + name: 'Malawi', + capital: 'Lilongwe', + languages: ['English', 'Chichewa'], + population: 16832910, + flag: 'https://restcountries.eu/data/mwi.svg', + currency: 'Malawian kwacha' + }, + { + name: 'Malaysia', + capital: 'Kuala Lumpur', + languages: ['Malaysian'], + population: 31405416, + flag: 'https://restcountries.eu/data/mys.svg', + currency: 'Malaysian ringgit' + }, + { + name: 'Maldives', + capital: 'Malé', + languages: ['Divehi'], + population: 344023, + flag: 'https://restcountries.eu/data/mdv.svg', + currency: 'Maldivian rufiyaa' + }, + { + name: 'Mali', + capital: 'Bamako', + languages: ['French'], + population: 18135000, + flag: 'https://restcountries.eu/data/mli.svg', + currency: 'West African CFA franc' + }, + { + name: 'Malta', + capital: 'Valletta', + languages: ['Maltese', 'English'], + population: 425384, + flag: 'https://restcountries.eu/data/mlt.svg', + currency: 'Euro' + }, + { + name: 'Marshall Islands', + capital: 'Majuro', + languages: ['English', 'Marshallese'], + population: 54880, + flag: 'https://restcountries.eu/data/mhl.svg', + currency: 'United States dollar' + }, + { + name: 'Martinique', + capital: 'Fort-de-France', + languages: ['French'], + population: 378243, + flag: 'https://restcountries.eu/data/mtq.svg', + currency: 'Euro' + }, + { + name: 'Mauritania', + capital: 'Nouakchott', + languages: ['Arabic'], + population: 3718678, + flag: 'https://restcountries.eu/data/mrt.svg', + currency: 'Mauritanian ouguiya' + }, + { + name: 'Mauritius', + capital: 'Port Louis', + languages: ['English'], + population: 1262879, + flag: 'https://restcountries.eu/data/mus.svg', + currency: 'Mauritian rupee' + }, + { + name: 'Mayotte', + capital: 'Mamoudzou', + languages: ['French'], + population: 226915, + flag: 'https://restcountries.eu/data/myt.svg', + currency: 'Euro' + }, + { + name: 'Mexico', + capital: 'Mexico City', + languages: ['Spanish'], + population: 122273473, + flag: 'https://restcountries.eu/data/mex.svg', + currency: 'Mexican peso' + }, + { + name: 'Micronesia (Federated States of)', + capital: 'Palikir', + languages: ['English'], + population: 102800, + flag: 'https://restcountries.eu/data/fsm.svg', + currency: '[D]' + }, + { + name: 'Moldova (Republic of)', + capital: 'Chișinău', + languages: ['Romanian'], + population: 3553100, + flag: 'https://restcountries.eu/data/mda.svg', + currency: 'Moldovan leu' + }, + { + name: 'Monaco', + capital: 'Monaco', + languages: ['French'], + population: 38400, + flag: 'https://restcountries.eu/data/mco.svg', + currency: 'Euro' + }, + { + name: 'Mongolia', + capital: 'Ulan Bator', + languages: ['Mongolian'], + population: 3093100, + flag: 'https://restcountries.eu/data/mng.svg', + currency: 'Mongolian tögrög' + }, + { + name: 'Montenegro', + capital: 'Podgorica', + languages: ['Serbian', 'Bosnian', 'Albanian', 'Croatian'], + population: 621810, + flag: 'https://restcountries.eu/data/mne.svg', + currency: 'Euro' + }, + { + name: 'Montserrat', + capital: 'Plymouth', + languages: ['English'], + population: 4922, + flag: 'https://restcountries.eu/data/msr.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Morocco', + capital: 'Rabat', + languages: ['Arabic'], + population: 33337529, + flag: 'https://restcountries.eu/data/mar.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Mozambique', + capital: 'Maputo', + languages: ['Portuguese'], + population: 26423700, + flag: 'https://restcountries.eu/data/moz.svg', + currency: 'Mozambican metical' + }, + { + name: 'Myanmar', + capital: 'Naypyidaw', + languages: ['Burmese'], + population: 51419420, + flag: 'https://restcountries.eu/data/mmr.svg', + currency: 'Burmese kyat' + }, + { + name: 'Namibia', + capital: 'Windhoek', + languages: ['English', 'Afrikaans'], + population: 2324388, + flag: 'https://restcountries.eu/data/nam.svg', + currency: 'Namibian dollar' + }, + { + name: 'Nauru', + capital: 'Yaren', + languages: ['English', 'Nauruan'], + population: 10084, + flag: 'https://restcountries.eu/data/nru.svg', + currency: 'Australian dollar' + }, + { + name: 'Nepal', + capital: 'Kathmandu', + languages: ['Nepali'], + population: 28431500, + flag: 'https://restcountries.eu/data/npl.svg', + currency: 'Nepalese rupee' + }, + { + name: 'Netherlands', + capital: 'Amsterdam', + languages: ['Dutch'], + population: 17019800, + flag: 'https://restcountries.eu/data/nld.svg', + currency: 'Euro' + }, + { + name: 'New Caledonia', + capital: 'Nouméa', + languages: ['French'], + population: 268767, + flag: 'https://restcountries.eu/data/ncl.svg', + currency: 'CFP franc' + }, + { + name: 'New Zealand', + capital: 'Wellington', + languages: ['English', 'Māori'], + population: 4697854, + flag: 'https://restcountries.eu/data/nzl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Nicaragua', + capital: 'Managua', + languages: ['Spanish'], + population: 6262703, + flag: 'https://restcountries.eu/data/nic.svg', + currency: 'Nicaraguan córdoba' + }, + { + name: 'Niger', + capital: 'Niamey', + languages: ['French'], + population: 20715000, + flag: 'https://restcountries.eu/data/ner.svg', + currency: 'West African CFA franc' + }, + { + name: 'Nigeria', + capital: 'Abuja', + languages: ['English'], + population: 186988000, + flag: 'https://restcountries.eu/data/nga.svg', + currency: 'Nigerian naira' + }, + { + name: 'Niue', + capital: 'Alofi', + languages: ['English'], + population: 1470, + flag: 'https://restcountries.eu/data/niu.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Norfolk Island', + capital: 'Kingston', + languages: ['English'], + population: 2302, + flag: 'https://restcountries.eu/data/nfk.svg', + currency: 'Australian dollar' + }, + { + name: "Korea (Democratic People's Republic of)", + capital: 'Pyongyang', + languages: ['Korean'], + population: 25281000, + flag: 'https://restcountries.eu/data/prk.svg', + currency: 'North Korean won' + }, + { + name: 'Northern Mariana Islands', + capital: 'Saipan', + languages: ['English', 'Chamorro'], + population: 56940, + flag: 'https://restcountries.eu/data/mnp.svg', + currency: 'United States dollar' + }, + { + name: 'Norway', + capital: 'Oslo', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 5223256, + flag: 'https://restcountries.eu/data/nor.svg', + currency: 'Norwegian krone' + }, + { + name: 'Oman', + capital: 'Muscat', + languages: ['Arabic'], + population: 4420133, + flag: 'https://restcountries.eu/data/omn.svg', + currency: 'Omani rial' + }, + { + name: 'Pakistan', + capital: 'Islamabad', + languages: ['English', 'Urdu'], + population: 194125062, + flag: 'https://restcountries.eu/data/pak.svg', + currency: 'Pakistani rupee' + }, + { + name: 'Palau', + capital: 'Ngerulmud', + languages: ['English'], + population: 17950, + flag: 'https://restcountries.eu/data/plw.svg', + currency: '[E]' + }, + { + name: 'Palestine, State of', + capital: 'Ramallah', + languages: ['Arabic'], + population: 4682467, + flag: 'https://restcountries.eu/data/pse.svg', + currency: 'Israeli new sheqel' + }, + { + name: 'Panama', + capital: 'Panama City', + languages: ['Spanish'], + population: 3814672, + flag: 'https://restcountries.eu/data/pan.svg', + currency: 'Panamanian balboa' + }, + { + name: 'Papua New Guinea', + capital: 'Port Moresby', + languages: ['English'], + population: 8083700, + flag: 'https://restcountries.eu/data/png.svg', + currency: 'Papua New Guinean kina' + }, + { + name: 'Paraguay', + capital: 'Asunción', + languages: ['Spanish', 'Guaraní'], + population: 6854536, + flag: 'https://restcountries.eu/data/pry.svg', + currency: 'Paraguayan guaraní' + }, + { + name: 'Peru', + capital: 'Lima', + languages: ['Spanish'], + population: 31488700, + flag: 'https://restcountries.eu/data/per.svg', + currency: 'Peruvian sol' + }, + { + name: 'Philippines', + capital: 'Manila', + languages: ['English'], + population: 103279800, + flag: 'https://restcountries.eu/data/phl.svg', + currency: 'Philippine peso' + }, + { + name: 'Pitcairn', + capital: 'Adamstown', + languages: ['English'], + population: 56, + flag: 'https://restcountries.eu/data/pcn.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Poland', + capital: 'Warsaw', + languages: ['Polish'], + population: 38437239, + flag: 'https://restcountries.eu/data/pol.svg', + currency: 'Polish złoty' + }, + { + name: 'Portugal', + capital: 'Lisbon', + languages: ['Portuguese'], + population: 10374822, + flag: 'https://restcountries.eu/data/prt.svg', + currency: 'Euro' + }, + { + name: 'Puerto Rico', + capital: 'San Juan', + languages: ['Spanish', 'English'], + population: 3474182, + flag: 'https://restcountries.eu/data/pri.svg', + currency: 'United States dollar' + }, + { + name: 'Qatar', + capital: 'Doha', + languages: ['Arabic'], + population: 2587564, + flag: 'https://restcountries.eu/data/qat.svg', + currency: 'Qatari riyal' + }, + { + name: 'Republic of Kosovo', + capital: 'Pristina', + languages: ['Albanian', 'Serbian'], + population: 1733842, + flag: 'https://restcountries.eu/data/kos.svg', + currency: 'Euro' + }, + { + name: 'Réunion', + capital: 'Saint-Denis', + languages: ['French'], + population: 840974, + flag: 'https://restcountries.eu/data/reu.svg', + currency: 'Euro' + }, + { + name: 'Romania', + capital: 'Bucharest', + languages: ['Romanian'], + population: 19861408, + flag: 'https://restcountries.eu/data/rou.svg', + currency: 'Romanian leu' + }, + { + name: 'Russian Federation', + capital: 'Moscow', + languages: ['Russian'], + population: 146599183, + flag: 'https://restcountries.eu/data/rus.svg', + currency: 'Russian ruble' + }, + { + name: 'Rwanda', + capital: 'Kigali', + languages: ['Kinyarwanda', 'English', 'French'], + population: 11553188, + flag: 'https://restcountries.eu/data/rwa.svg', + currency: 'Rwandan franc' + }, + { + name: 'Saint Barthélemy', + capital: 'Gustavia', + languages: ['French'], + population: 9417, + flag: 'https://restcountries.eu/data/blm.svg', + currency: 'Euro' + }, + { + name: 'Saint Helena, Ascension and Tristan da Cunha', + capital: 'Jamestown', + languages: ['English'], + population: 4255, + flag: 'https://restcountries.eu/data/shn.svg', + currency: 'Saint Helena pound' + }, + { + name: 'Saint Kitts and Nevis', + capital: 'Basseterre', + languages: ['English'], + population: 46204, + flag: 'https://restcountries.eu/data/kna.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Lucia', + capital: 'Castries', + languages: ['English'], + population: 186000, + flag: 'https://restcountries.eu/data/lca.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Martin (French part)', + capital: 'Marigot', + languages: ['English', 'French', 'Dutch'], + population: 36979, + flag: 'https://restcountries.eu/data/maf.svg', + currency: 'Euro' + }, + { + name: 'Saint Pierre and Miquelon', + capital: 'Saint-Pierre', + languages: ['French'], + population: 6069, + flag: 'https://restcountries.eu/data/spm.svg', + currency: 'Euro' + }, + { + name: 'Saint Vincent and the Grenadines', + capital: 'Kingstown', + languages: ['English'], + population: 109991, + flag: 'https://restcountries.eu/data/vct.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Samoa', + capital: 'Apia', + languages: ['Samoan', 'English'], + population: 194899, + flag: 'https://restcountries.eu/data/wsm.svg', + currency: 'Samoan tālā' + }, + { + name: 'San Marino', + capital: 'City of San Marino', + languages: ['Italian'], + population: 33005, + flag: 'https://restcountries.eu/data/smr.svg', + currency: 'Euro' + }, + { + name: 'Sao Tome and Principe', + capital: 'São Tomé', + languages: ['Portuguese'], + population: 187356, + flag: 'https://restcountries.eu/data/stp.svg', + currency: 'São Tomé and Príncipe dobra' + }, + { + name: 'Saudi Arabia', + capital: 'Riyadh', + languages: ['Arabic'], + population: 32248200, + flag: 'https://restcountries.eu/data/sau.svg', + currency: 'Saudi riyal' + }, + { + name: 'Senegal', + capital: 'Dakar', + languages: ['French'], + population: 14799859, + flag: 'https://restcountries.eu/data/sen.svg', + currency: 'West African CFA franc' + }, + { + name: 'Serbia', + capital: 'Belgrade', + languages: ['Serbian'], + population: 7076372, + flag: 'https://restcountries.eu/data/srb.svg', + currency: 'Serbian dinar' + }, + { + name: 'Seychelles', + capital: 'Victoria', + languages: ['French', 'English'], + population: 91400, + flag: 'https://restcountries.eu/data/syc.svg', + currency: 'Seychellois rupee' + }, + { + name: 'Sierra Leone', + capital: 'Freetown', + languages: ['English'], + population: 7075641, + flag: 'https://restcountries.eu/data/sle.svg', + currency: 'Sierra Leonean leone' + }, + { + name: 'Singapore', + capital: 'Singapore', + languages: ['English', 'Malay', 'Tamil', 'Chinese'], + population: 5535000, + flag: 'https://restcountries.eu/data/sgp.svg', + currency: 'Brunei dollar' + }, + { + name: 'Sint Maarten (Dutch part)', + capital: 'Philipsburg', + languages: ['Dutch', 'English'], + population: 38247, + flag: 'https://restcountries.eu/data/sxm.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Slovakia', + capital: 'Bratislava', + languages: ['Slovak'], + population: 5426252, + flag: 'https://restcountries.eu/data/svk.svg', + currency: 'Euro' + }, + { + name: 'Slovenia', + capital: 'Ljubljana', + languages: ['Slovene'], + population: 2064188, + flag: 'https://restcountries.eu/data/svn.svg', + currency: 'Euro' + }, + { + name: 'Solomon Islands', + capital: 'Honiara', + languages: ['English'], + population: 642000, + flag: 'https://restcountries.eu/data/slb.svg', + currency: 'Solomon Islands dollar' + }, + { + name: 'Somalia', + capital: 'Mogadishu', + languages: ['Somali', 'Arabic'], + population: 11079000, + flag: 'https://restcountries.eu/data/som.svg', + currency: 'Somali shilling' + }, + { + name: 'South Africa', + capital: 'Pretoria', + languages: [ + 'Afrikaans', + 'English', + 'Southern Ndebele', + 'Southern Sotho', + 'Swati', + 'Tswana', + 'Tsonga', + 'Venda', + 'Xhosa', + 'Zulu' + ], + population: 55653654, + flag: 'https://restcountries.eu/data/zaf.svg', + currency: 'South African rand' + }, + { + name: 'South Georgia and the South Sandwich Islands', + capital: 'King Edward Point', + languages: ['English'], + population: 30, + flag: 'https://restcountries.eu/data/sgs.svg', + currency: 'British pound' + }, + { + name: 'Korea (Republic of)', + capital: 'Seoul', + languages: ['Korean'], + population: 50801405, + flag: 'https://restcountries.eu/data/kor.svg', + currency: 'South Korean won' + }, + { + name: 'South Sudan', + capital: 'Juba', + languages: ['English'], + population: 12131000, + flag: 'https://restcountries.eu/data/ssd.svg', + currency: 'South Sudanese pound' + }, + { + name: 'Spain', + capital: 'Madrid', + languages: ['Spanish'], + population: 46438422, + flag: 'https://restcountries.eu/data/esp.svg', + currency: 'Euro' + }, + { + name: 'Sri Lanka', + capital: 'Colombo', + languages: ['Sinhalese', 'Tamil'], + population: 20966000, + flag: 'https://restcountries.eu/data/lka.svg', + currency: 'Sri Lankan rupee' + }, + { + name: 'Sudan', + capital: 'Khartoum', + languages: ['Arabic', 'English'], + population: 39598700, + flag: 'https://restcountries.eu/data/sdn.svg', + currency: 'Sudanese pound' + }, + { + name: 'Suriname', + capital: 'Paramaribo', + languages: ['Dutch'], + population: 541638, + flag: 'https://restcountries.eu/data/sur.svg', + currency: 'Surinamese dollar' + }, + { + name: 'Svalbard and Jan Mayen', + capital: 'Longyearbyen', + languages: ['Norwegian'], + population: 2562, + flag: 'https://restcountries.eu/data/sjm.svg', + currency: 'Norwegian krone' + }, + { + name: 'Swaziland', + capital: 'Lobamba', + languages: ['English', 'Swati'], + population: 1132657, + flag: 'https://restcountries.eu/data/swz.svg', + currency: 'Swazi lilangeni' + }, + { + name: 'Sweden', + capital: 'Stockholm', + languages: ['Swedish'], + population: 9894888, + flag: 'https://restcountries.eu/data/swe.svg', + currency: 'Swedish krona' + }, + { + name: 'Switzerland', + capital: 'Bern', + languages: ['German', 'French', 'Italian'], + population: 8341600, + flag: 'https://restcountries.eu/data/che.svg', + currency: 'Swiss franc' + }, + { + name: 'Syrian Arab Republic', + capital: 'Damascus', + languages: ['Arabic'], + population: 18564000, + flag: 'https://restcountries.eu/data/syr.svg', + currency: 'Syrian pound' + }, + { + name: 'Taiwan', + capital: 'Taipei', + languages: ['Chinese'], + population: 23503349, + flag: 'https://restcountries.eu/data/twn.svg', + currency: 'New Taiwan dollar' + }, + { + name: 'Tajikistan', + capital: 'Dushanbe', + languages: ['Tajik', 'Russian'], + population: 8593600, + flag: 'https://restcountries.eu/data/tjk.svg', + currency: 'Tajikistani somoni' + }, + { + name: 'Tanzania, United Republic of', + capital: 'Dodoma', + languages: ['Swahili', 'English'], + population: 55155000, + flag: 'https://restcountries.eu/data/tza.svg', + currency: 'Tanzanian shilling' + }, + { + name: 'Thailand', + capital: 'Bangkok', + languages: ['Thai'], + population: 65327652, + flag: 'https://restcountries.eu/data/tha.svg', + currency: 'Thai baht' + }, + { + name: 'Timor-Leste', + capital: 'Dili', + languages: ['Portuguese'], + population: 1167242, + flag: 'https://restcountries.eu/data/tls.svg', + currency: 'United States dollar' + }, + { + name: 'Togo', + capital: 'Lomé', + languages: ['French'], + population: 7143000, + flag: 'https://restcountries.eu/data/tgo.svg', + currency: 'West African CFA franc' + }, + { + name: 'Tokelau', + capital: 'Fakaofo', + languages: ['English'], + population: 1411, + flag: 'https://restcountries.eu/data/tkl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Tonga', + capital: "Nuku'alofa", + languages: ['English', 'Tonga (Tonga Islands)'], + population: 103252, + flag: 'https://restcountries.eu/data/ton.svg', + currency: 'Tongan paʻanga' + }, + { + name: 'Trinidad and Tobago', + capital: 'Port of Spain', + languages: ['English'], + population: 1349667, + flag: 'https://restcountries.eu/data/tto.svg', + currency: 'Trinidad and Tobago dollar' + }, + { + name: 'Tunisia', + capital: 'Tunis', + languages: ['Arabic'], + population: 11154400, + flag: 'https://restcountries.eu/data/tun.svg', + currency: 'Tunisian dinar' + }, + { + name: 'Turkey', + capital: 'Ankara', + languages: ['Turkish'], + population: 78741053, + flag: 'https://restcountries.eu/data/tur.svg', + currency: 'Turkish lira' + }, + { + name: 'Turkmenistan', + capital: 'Ashgabat', + languages: ['Turkmen', 'Russian'], + population: 4751120, + flag: 'https://restcountries.eu/data/tkm.svg', + currency: 'Turkmenistan manat' + }, + { + name: 'Turks and Caicos Islands', + capital: 'Cockburn Town', + languages: ['English'], + population: 31458, + flag: 'https://restcountries.eu/data/tca.svg', + currency: 'United States dollar' + }, + { + name: 'Tuvalu', + capital: 'Funafuti', + languages: ['English'], + population: 10640, + flag: 'https://restcountries.eu/data/tuv.svg', + currency: 'Australian dollar' + }, + { + name: 'Uganda', + capital: 'Kampala', + languages: ['English', 'Swahili'], + population: 33860700, + flag: 'https://restcountries.eu/data/uga.svg', + currency: 'Ugandan shilling' + }, + { + name: 'Ukraine', + capital: 'Kiev', + languages: ['Ukrainian'], + population: 42692393, + flag: 'https://restcountries.eu/data/ukr.svg', + currency: 'Ukrainian hryvnia' + }, + { + name: 'United Arab Emirates', + capital: 'Abu Dhabi', + languages: ['Arabic'], + population: 9856000, + flag: 'https://restcountries.eu/data/are.svg', + currency: 'United Arab Emirates dirham' + }, + { + name: 'United Kingdom of Great Britain and Northern Ireland', + capital: 'London', + languages: ['English'], + population: 65110000, + flag: 'https://restcountries.eu/data/gbr.svg', + currency: 'British pound' + }, + { + name: 'United States of America', + capital: 'Washington, D.C.', + languages: ['English'], + population: 323947000, + flag: 'https://restcountries.eu/data/usa.svg', + currency: 'United States dollar' + }, + { + name: 'Uruguay', + capital: 'Montevideo', + languages: ['Spanish'], + population: 3480222, + flag: 'https://restcountries.eu/data/ury.svg', + currency: 'Uruguayan peso' + }, + { + name: 'Uzbekistan', + capital: 'Tashkent', + languages: ['Uzbek', 'Russian'], + population: 31576400, + flag: 'https://restcountries.eu/data/uzb.svg', + currency: "Uzbekistani so'm" + }, + { + name: 'Vanuatu', + capital: 'Port Vila', + languages: ['Bislama', 'English', 'French'], + population: 277500, + flag: 'https://restcountries.eu/data/vut.svg', + currency: 'Vanuatu vatu' + }, + { + name: 'Venezuela (Bolivarian Republic of)', + capital: 'Caracas', + languages: ['Spanish'], + population: 31028700, + flag: 'https://restcountries.eu/data/ven.svg', + currency: 'Venezuelan bolívar' + }, + { + name: 'Viet Nam', + capital: 'Hanoi', + languages: ['Vietnamese'], + population: 92700000, + flag: 'https://restcountries.eu/data/vnm.svg', + currency: 'Vietnamese đồng' + }, + { + name: 'Wallis and Futuna', + capital: 'Mata-Utu', + languages: ['French'], + population: 11750, + flag: 'https://restcountries.eu/data/wlf.svg', + currency: 'CFP franc' + }, + { + name: 'Western Sahara', + capital: 'El Aaiún', + languages: ['Spanish'], + population: 510713, + flag: 'https://restcountries.eu/data/esh.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Yemen', + capital: "Sana'a", + languages: ['Arabic'], + population: 27478000, + flag: 'https://restcountries.eu/data/yem.svg', + currency: 'Yemeni rial' + }, + { + name: 'Zambia', + capital: 'Lusaka', + languages: ['English'], + population: 15933883, + flag: 'https://restcountries.eu/data/zmb.svg', + currency: 'Zambian kwacha' + }, + { + name: 'Zimbabwe', + capital: 'Harare', + languages: ['English', 'Shona', 'Northern Ndebele'], + population: 14240168, + flag: 'https://restcountries.eu/data/zwe.svg', + currency: 'Botswana pula' + } +] diff --git a/18_Day_Promises/18_day_starter/index.html b/18_Day_Promises/18_day_starter/index.html new file mode 100644 index 0000000..a0103b7 --- /dev/null +++ b/18_Day_Promises/18_day_starter/index.html @@ -0,0 +1,17 @@ + + + + + 30DaysOfJavaScript:18 Day + + + +

30DaysOfJavaScript:18 Day

+

Promises

+ + + + + + + \ No newline at end of file diff --git a/18_Day_Promises/18_day_starter/scripts/main.js b/18_Day_Promises/18_day_starter/scripts/main.js new file mode 100644 index 0000000..c6045c8 --- /dev/null +++ b/18_Day_Promises/18_day_starter/scripts/main.js @@ -0,0 +1,2 @@ +console.log(countries) +alert('Open the console and check if the countries has been loaded') \ No newline at end of file diff --git a/19_Day_Closures/19_day_closures.md b/19_Day_Closures/19_day_closures.md new file mode 100644 index 0000000..4c96016 --- /dev/null +++ b/19_Day_Closures/19_day_closures.md @@ -0,0 +1,104 @@ +
+

30 Days Of JavaScript: Closures

+ + + + + Twitter Follow + + +Author: +Asabeneh Yetayeh
+ January, 2020 +
+ +
+ +[<< Day 18](../18_Day_Promises/18_day_promise.md) | [Day 20 >>](../20_Day_Writing_clean_codes/20_day_writing_clean_codes.md) + +![Thirty Days Of JavaScript](../images/banners/day_1_19.png) +- [Day 19](#day-19) + - [Closure](#closure) + - [Exercises](#exercises) + - [Exercises: Level 1](#exercises-level-1) + - [Exercises: Level 2](#exercises-level-2) + - [Exercises: Level 3](#exercises-level-3) + +# Day 19 + +## Closure + +JavaScript allows writing function inside an outer function. We can write as many inner functions as we want. If inner function access the variables of outer function then it is called closure. + +```js +function outerFunction() { + let count = 0; + function innerFunction() { + count++ + return count + } + + return innerFunction +} +const innerFunc = outerFunction() + +console.log(innerFunc()) +console.log(innerFunc()) +console.log(innerFunc()) +``` + +```sh +1 +2 +3 +``` + +Let us more example of inner functions + +```js +function outerFunction() { + let count = 0; + function plusOne() { + count++ + return count + } + function minusOne() { + count-- + return count + } + + return { + plusOne:plusOne(), + minusOne:minusOne() + } +} +const innerFuncs = outerFunction() + +console.log(innerFuncs.plusOne) +console.log(innerFuncs.minusOne) +``` + +```sh +1 +1 +``` + +🌕 You are making progress. Maintain your momentum, keep the good work. Now do some exercises for your brain and for your muscle. + +## Exercises + +### Exercises: Level 1 + +1. Create a closure which has one inner function + +### Exercises: Level 2 + +1. Create a closure which has three inner functions + +### Exercises: Level 3 + +1. Create a personAccount out function. It has firstname, lastname, incomes, expenses inner variables. It has totalIncome, totalExpense, accountInfo,addIncome, addExpense and accountBalance inner functions. Incomes is a set of incomes and its description and expenses is also a set of expenses and its description. + +🎉 CONGRATULATIONS ! 🎉 + +[<< Day 18](../18_Day_Promises/18_day_promise.md) | [Day 20 >>](../20_Day_Writing_clean_codes/20_day_writing_clean_codes.md) \ No newline at end of file diff --git a/19_Day_Closures/19_day_starter/data/countries_data.js b/19_Day_Closures/19_day_starter/data/countries_data.js new file mode 100644 index 0000000..92acddd --- /dev/null +++ b/19_Day_Closures/19_day_starter/data/countries_data.js @@ -0,0 +1,2013 @@ +const countries = [ + { + name: 'Afghanistan', + capital: 'Kabul', + languages: ['Pashto', 'Uzbek', 'Turkmen'], + population: 27657145, + flag: 'https://restcountries.eu/data/afg.svg', + currency: 'Afghan afghani' + }, + { + name: 'Åland Islands', + capital: 'Mariehamn', + languages: ['Swedish'], + population: 28875, + flag: 'https://restcountries.eu/data/ala.svg', + currency: 'Euro' + }, + { + name: 'Albania', + capital: 'Tirana', + languages: ['Albanian'], + population: 2886026, + flag: 'https://restcountries.eu/data/alb.svg', + currency: 'Albanian lek' + }, + { + name: 'Algeria', + capital: 'Algiers', + languages: ['Arabic'], + population: 40400000, + flag: 'https://restcountries.eu/data/dza.svg', + currency: 'Algerian dinar' + }, + { + name: 'American Samoa', + capital: 'Pago Pago', + languages: ['English', 'Samoan'], + population: 57100, + flag: 'https://restcountries.eu/data/asm.svg', + currency: 'United State Dollar' + }, + { + name: 'Andorra', + capital: 'Andorra la Vella', + languages: ['Catalan'], + population: 78014, + flag: 'https://restcountries.eu/data/and.svg', + currency: 'Euro' + }, + { + name: 'Angola', + capital: 'Luanda', + languages: ['Portuguese'], + population: 25868000, + flag: 'https://restcountries.eu/data/ago.svg', + currency: 'Angolan kwanza' + }, + { + name: 'Anguilla', + capital: 'The Valley', + languages: ['English'], + population: 13452, + flag: 'https://restcountries.eu/data/aia.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Antarctica', + capital: '', + languages: ['English', 'Russian'], + population: 1000, + flag: 'https://restcountries.eu/data/ata.svg', + currency: 'Australian dollar' + }, + { + name: 'Antigua and Barbuda', + capital: "Saint John's", + languages: ['English'], + population: 86295, + flag: 'https://restcountries.eu/data/atg.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Argentina', + capital: 'Buenos Aires', + languages: ['Spanish', 'Guaraní'], + population: 43590400, + flag: 'https://restcountries.eu/data/arg.svg', + currency: 'Argentine peso' + }, + { + name: 'Armenia', + capital: 'Yerevan', + languages: ['Armenian', 'Russian'], + population: 2994400, + flag: 'https://restcountries.eu/data/arm.svg', + currency: 'Armenian dram' + }, + { + name: 'Aruba', + capital: 'Oranjestad', + languages: ['Dutch', '(Eastern) Punjabi'], + population: 107394, + flag: 'https://restcountries.eu/data/abw.svg', + currency: 'Aruban florin' + }, + { + name: 'Australia', + capital: 'Canberra', + languages: ['English'], + population: 24117360, + flag: 'https://restcountries.eu/data/aus.svg', + currency: 'Australian dollar' + }, + { + name: 'Austria', + capital: 'Vienna', + languages: ['German'], + population: 8725931, + flag: 'https://restcountries.eu/data/aut.svg', + currency: 'Euro' + }, + { + name: 'Azerbaijan', + capital: 'Baku', + languages: ['Azerbaijani'], + population: 9730500, + flag: 'https://restcountries.eu/data/aze.svg', + currency: 'Azerbaijani manat' + }, + { + name: 'Bahamas', + capital: 'Nassau', + languages: ['English'], + population: 378040, + flag: 'https://restcountries.eu/data/bhs.svg', + currency: 'Bahamian dollar' + }, + { + name: 'Bahrain', + capital: 'Manama', + languages: ['Arabic'], + population: 1404900, + flag: 'https://restcountries.eu/data/bhr.svg', + currency: 'Bahraini dinar' + }, + { + name: 'Bangladesh', + capital: 'Dhaka', + languages: ['Bengali'], + population: 161006790, + flag: 'https://restcountries.eu/data/bgd.svg', + currency: 'Bangladeshi taka' + }, + { + name: 'Barbados', + capital: 'Bridgetown', + languages: ['English'], + population: 285000, + flag: 'https://restcountries.eu/data/brb.svg', + currency: 'Barbadian dollar' + }, + { + name: 'Belarus', + capital: 'Minsk', + languages: ['Belarusian', 'Russian'], + population: 9498700, + flag: 'https://restcountries.eu/data/blr.svg', + currency: 'New Belarusian ruble' + }, + { + name: 'Belgium', + capital: 'Brussels', + languages: ['Dutch', 'French', 'German'], + population: 11319511, + flag: 'https://restcountries.eu/data/bel.svg', + currency: 'Euro' + }, + { + name: 'Belize', + capital: 'Belmopan', + languages: ['English', 'Spanish'], + population: 370300, + flag: 'https://restcountries.eu/data/blz.svg', + currency: 'Belize dollar' + }, + { + name: 'Benin', + capital: 'Porto-Novo', + languages: ['French'], + population: 10653654, + flag: 'https://restcountries.eu/data/ben.svg', + currency: 'West African CFA franc' + }, + { + name: 'Bermuda', + capital: 'Hamilton', + languages: ['English'], + population: 61954, + flag: 'https://restcountries.eu/data/bmu.svg', + currency: 'Bermudian dollar' + }, + { + name: 'Bhutan', + capital: 'Thimphu', + languages: ['Dzongkha'], + population: 775620, + flag: 'https://restcountries.eu/data/btn.svg', + currency: 'Bhutanese ngultrum' + }, + { + name: 'Bolivia (Plurinational State of)', + capital: 'Sucre', + languages: ['Spanish', 'Aymara', 'Quechua'], + population: 10985059, + flag: 'https://restcountries.eu/data/bol.svg', + currency: 'Bolivian boliviano' + }, + { + name: 'Bonaire, Sint Eustatius and Saba', + capital: 'Kralendijk', + languages: ['Dutch'], + population: 17408, + flag: 'https://restcountries.eu/data/bes.svg', + currency: 'United States dollar' + }, + { + name: 'Bosnia and Herzegovina', + capital: 'Sarajevo', + languages: ['Bosnian', 'Croatian', 'Serbian'], + population: 3531159, + flag: 'https://restcountries.eu/data/bih.svg', + currency: 'Bosnia and Herzegovina convertible mark' + }, + { + name: 'Botswana', + capital: 'Gaborone', + languages: ['English', 'Tswana'], + population: 2141206, + flag: 'https://restcountries.eu/data/bwa.svg', + currency: 'Botswana pula' + }, + { + name: 'Bouvet Island', + capital: '', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 0, + flag: 'https://restcountries.eu/data/bvt.svg', + currency: 'Norwegian krone' + }, + { + name: 'Brazil', + capital: 'Brasília', + languages: ['Portuguese'], + population: 206135893, + flag: 'https://restcountries.eu/data/bra.svg', + currency: 'Brazilian real' + }, + { + name: 'British Indian Ocean Territory', + capital: 'Diego Garcia', + languages: ['English'], + population: 3000, + flag: 'https://restcountries.eu/data/iot.svg', + currency: 'United States dollar' + }, + { + name: 'United States Minor Outlying Islands', + capital: '', + languages: ['English'], + population: 300, + flag: 'https://restcountries.eu/data/umi.svg', + currency: 'United States Dollar' + }, + { + name: 'Virgin Islands (British)', + capital: 'Road Town', + languages: ['English'], + population: 28514, + flag: 'https://restcountries.eu/data/vgb.svg', + currency: '[D]' + }, + { + name: 'Virgin Islands (U.S.)', + capital: 'Charlotte Amalie', + languages: ['English'], + population: 114743, + flag: 'https://restcountries.eu/data/vir.svg', + currency: 'United States dollar' + }, + { + name: 'Brunei Darussalam', + capital: 'Bandar Seri Begawan', + languages: ['Malay'], + population: 411900, + flag: 'https://restcountries.eu/data/brn.svg', + currency: 'Brunei dollar' + }, + { + name: 'Bulgaria', + capital: 'Sofia', + languages: ['Bulgarian'], + population: 7153784, + flag: 'https://restcountries.eu/data/bgr.svg', + currency: 'Bulgarian lev' + }, + { + name: 'Burkina Faso', + capital: 'Ouagadougou', + languages: ['French', 'Fula'], + population: 19034397, + flag: 'https://restcountries.eu/data/bfa.svg', + currency: 'West African CFA franc' + }, + { + name: 'Burundi', + capital: 'Bujumbura', + languages: ['French', 'Kirundi'], + population: 10114505, + flag: 'https://restcountries.eu/data/bdi.svg', + currency: 'Burundian franc' + }, + { + name: 'Cambodia', + capital: 'Phnom Penh', + languages: ['Khmer'], + population: 15626444, + flag: 'https://restcountries.eu/data/khm.svg', + currency: 'Cambodian riel' + }, + { + name: 'Cameroon', + capital: 'Yaoundé', + languages: ['English', 'French'], + population: 22709892, + flag: 'https://restcountries.eu/data/cmr.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Canada', + capital: 'Ottawa', + languages: ['English', 'French'], + population: 36155487, + flag: 'https://restcountries.eu/data/can.svg', + currency: 'Canadian dollar' + }, + { + name: 'Cabo Verde', + capital: 'Praia', + languages: ['Portuguese'], + population: 531239, + flag: 'https://restcountries.eu/data/cpv.svg', + currency: 'Cape Verdean escudo' + }, + { + name: 'Cayman Islands', + capital: 'George Town', + languages: ['English'], + population: 58238, + flag: 'https://restcountries.eu/data/cym.svg', + currency: 'Cayman Islands dollar' + }, + { + name: 'Central African Republic', + capital: 'Bangui', + languages: ['French', 'Sango'], + population: 4998000, + flag: 'https://restcountries.eu/data/caf.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chad', + capital: "N'Djamena", + languages: ['French', 'Arabic'], + population: 14497000, + flag: 'https://restcountries.eu/data/tcd.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chile', + capital: 'Santiago', + languages: ['Spanish'], + population: 18191900, + flag: 'https://restcountries.eu/data/chl.svg', + currency: 'Chilean peso' + }, + { + name: 'China', + capital: 'Beijing', + languages: ['Chinese'], + population: 1377422166, + flag: 'https://restcountries.eu/data/chn.svg', + currency: 'Chinese yuan' + }, + { + name: 'Christmas Island', + capital: 'Flying Fish Cove', + languages: ['English'], + population: 2072, + flag: 'https://restcountries.eu/data/cxr.svg', + currency: 'Australian dollar' + }, + { + name: 'Cocos (Keeling) Islands', + capital: 'West Island', + languages: ['English'], + population: 550, + flag: 'https://restcountries.eu/data/cck.svg', + currency: 'Australian dollar' + }, + { + name: 'Colombia', + capital: 'Bogotá', + languages: ['Spanish'], + population: 48759958, + flag: 'https://restcountries.eu/data/col.svg', + currency: 'Colombian peso' + }, + { + name: 'Comoros', + capital: 'Moroni', + languages: ['Arabic', 'French'], + population: 806153, + flag: 'https://restcountries.eu/data/com.svg', + currency: 'Comorian franc' + }, + { + name: 'Congo', + capital: 'Brazzaville', + languages: ['French', 'Lingala'], + population: 4741000, + flag: 'https://restcountries.eu/data/cog.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Congo (Democratic Republic of the)', + capital: 'Kinshasa', + languages: ['French', 'Lingala', 'Kongo', 'Swahili', 'Luba-Katanga'], + population: 85026000, + flag: 'https://restcountries.eu/data/cod.svg', + currency: 'Congolese franc' + }, + { + name: 'Cook Islands', + capital: 'Avarua', + languages: ['English'], + population: 18100, + flag: 'https://restcountries.eu/data/cok.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Costa Rica', + capital: 'San José', + languages: ['Spanish'], + population: 4890379, + flag: 'https://restcountries.eu/data/cri.svg', + currency: 'Costa Rican colón' + }, + { + name: 'Croatia', + capital: 'Zagreb', + languages: ['Croatian'], + population: 4190669, + flag: 'https://restcountries.eu/data/hrv.svg', + currency: 'Croatian kuna' + }, + { + name: 'Cuba', + capital: 'Havana', + languages: ['Spanish'], + population: 11239004, + flag: 'https://restcountries.eu/data/cub.svg', + currency: 'Cuban convertible peso' + }, + { + name: 'Curaçao', + capital: 'Willemstad', + languages: ['Dutch', '(Eastern) Punjabi', 'English'], + population: 154843, + flag: 'https://restcountries.eu/data/cuw.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Cyprus', + capital: 'Nicosia', + languages: ['Greek (modern)', 'Turkish', 'Armenian'], + population: 847000, + flag: 'https://restcountries.eu/data/cyp.svg', + currency: 'Euro' + }, + { + name: 'Czech Republic', + capital: 'Prague', + languages: ['Czech', 'Slovak'], + population: 10558524, + flag: 'https://restcountries.eu/data/cze.svg', + currency: 'Czech koruna' + }, + { + name: 'Denmark', + capital: 'Copenhagen', + languages: ['Danish'], + population: 5717014, + flag: 'https://restcountries.eu/data/dnk.svg', + currency: 'Danish krone' + }, + { + name: 'Djibouti', + capital: 'Djibouti', + languages: ['French', 'Arabic'], + population: 900000, + flag: 'https://restcountries.eu/data/dji.svg', + currency: 'Djiboutian franc' + }, + { + name: 'Dominica', + capital: 'Roseau', + languages: ['English'], + population: 71293, + flag: 'https://restcountries.eu/data/dma.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Dominican Republic', + capital: 'Santo Domingo', + languages: ['Spanish'], + population: 10075045, + flag: 'https://restcountries.eu/data/dom.svg', + currency: 'Dominican peso' + }, + { + name: 'Ecuador', + capital: 'Quito', + languages: ['Spanish'], + population: 16545799, + flag: 'https://restcountries.eu/data/ecu.svg', + currency: 'United States dollar' + }, + { + name: 'Egypt', + capital: 'Cairo', + languages: ['Arabic'], + population: 91290000, + flag: 'https://restcountries.eu/data/egy.svg', + currency: 'Egyptian pound' + }, + { + name: 'El Salvador', + capital: 'San Salvador', + languages: ['Spanish'], + population: 6520675, + flag: 'https://restcountries.eu/data/slv.svg', + currency: 'United States dollar' + }, + { + name: 'Equatorial Guinea', + capital: 'Malabo', + languages: ['Spanish', 'French'], + population: 1222442, + flag: 'https://restcountries.eu/data/gnq.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Eritrea', + capital: 'Asmara', + languages: ['Tigrinya', 'Arabic', 'English'], + population: 5352000, + flag: 'https://restcountries.eu/data/eri.svg', + currency: 'Eritrean nakfa' + }, + { + name: 'Estonia', + capital: 'Tallinn', + languages: ['Estonian'], + population: 1315944, + flag: 'https://restcountries.eu/data/est.svg', + currency: 'Euro' + }, + { + name: 'Ethiopia', + capital: 'Addis Ababa', + languages: ['Amharic'], + population: 92206005, + flag: 'https://restcountries.eu/data/eth.svg', + currency: 'Ethiopian birr' + }, + { + name: 'Falkland Islands (Malvinas)', + capital: 'Stanley', + languages: ['English'], + population: 2563, + flag: 'https://restcountries.eu/data/flk.svg', + currency: 'Falkland Islands pound' + }, + { + name: 'Faroe Islands', + capital: 'Tórshavn', + languages: ['Faroese'], + population: 49376, + flag: 'https://restcountries.eu/data/fro.svg', + currency: 'Danish krone' + }, + { + name: 'Fiji', + capital: 'Suva', + languages: ['English', 'Fijian', 'Hindi', 'Urdu'], + population: 867000, + flag: 'https://restcountries.eu/data/fji.svg', + currency: 'Fijian dollar' + }, + { + name: 'Finland', + capital: 'Helsinki', + languages: ['Finnish', 'Swedish'], + population: 5491817, + flag: 'https://restcountries.eu/data/fin.svg', + currency: 'Euro' + }, + { + name: 'France', + capital: 'Paris', + languages: ['French'], + population: 66710000, + flag: 'https://restcountries.eu/data/fra.svg', + currency: 'Euro' + }, + { + name: 'French Guiana', + capital: 'Cayenne', + languages: ['French'], + population: 254541, + flag: 'https://restcountries.eu/data/guf.svg', + currency: 'Euro' + }, + { + name: 'French Polynesia', + capital: 'Papeetē', + languages: ['French'], + population: 271800, + flag: 'https://restcountries.eu/data/pyf.svg', + currency: 'CFP franc' + }, + { + name: 'French Southern Territories', + capital: 'Port-aux-Français', + languages: ['French'], + population: 140, + flag: 'https://restcountries.eu/data/atf.svg', + currency: 'Euro' + }, + { + name: 'Gabon', + capital: 'Libreville', + languages: ['French'], + population: 1802278, + flag: 'https://restcountries.eu/data/gab.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Gambia', + capital: 'Banjul', + languages: ['English'], + population: 1882450, + flag: 'https://restcountries.eu/data/gmb.svg', + currency: 'Gambian dalasi' + }, + { + name: 'Georgia', + capital: 'Tbilisi', + languages: ['Georgian'], + population: 3720400, + flag: 'https://restcountries.eu/data/geo.svg', + currency: 'Georgian Lari' + }, + { + name: 'Germany', + capital: 'Berlin', + languages: ['German'], + population: 81770900, + flag: 'https://restcountries.eu/data/deu.svg', + currency: 'Euro' + }, + { + name: 'Ghana', + capital: 'Accra', + languages: ['English'], + population: 27670174, + flag: 'https://restcountries.eu/data/gha.svg', + currency: 'Ghanaian cedi' + }, + { + name: 'Gibraltar', + capital: 'Gibraltar', + languages: ['English'], + population: 33140, + flag: 'https://restcountries.eu/data/gib.svg', + currency: 'Gibraltar pound' + }, + { + name: 'Greece', + capital: 'Athens', + languages: ['Greek (modern)'], + population: 10858018, + flag: 'https://restcountries.eu/data/grc.svg', + currency: 'Euro' + }, + { + name: 'Greenland', + capital: 'Nuuk', + languages: ['Kalaallisut'], + population: 55847, + flag: 'https://restcountries.eu/data/grl.svg', + currency: 'Danish krone' + }, + { + name: 'Grenada', + capital: "St. George's", + languages: ['English'], + population: 103328, + flag: 'https://restcountries.eu/data/grd.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Guadeloupe', + capital: 'Basse-Terre', + languages: ['French'], + population: 400132, + flag: 'https://restcountries.eu/data/glp.svg', + currency: 'Euro' + }, + { + name: 'Guam', + capital: 'Hagåtña', + languages: ['English', 'Chamorro', 'Spanish'], + population: 184200, + flag: 'https://restcountries.eu/data/gum.svg', + currency: 'United States dollar' + }, + { + name: 'Guatemala', + capital: 'Guatemala City', + languages: ['Spanish'], + population: 16176133, + flag: 'https://restcountries.eu/data/gtm.svg', + currency: 'Guatemalan quetzal' + }, + { + name: 'Guernsey', + capital: 'St. Peter Port', + languages: ['English', 'French'], + population: 62999, + flag: 'https://restcountries.eu/data/ggy.svg', + currency: 'British pound' + }, + { + name: 'Guinea', + capital: 'Conakry', + languages: ['French', 'Fula'], + population: 12947000, + flag: 'https://restcountries.eu/data/gin.svg', + currency: 'Guinean franc' + }, + { + name: 'Guinea-Bissau', + capital: 'Bissau', + languages: ['Portuguese'], + population: 1547777, + flag: 'https://restcountries.eu/data/gnb.svg', + currency: 'West African CFA franc' + }, + { + name: 'Guyana', + capital: 'Georgetown', + languages: ['English'], + population: 746900, + flag: 'https://restcountries.eu/data/guy.svg', + currency: 'Guyanese dollar' + }, + { + name: 'Haiti', + capital: 'Port-au-Prince', + languages: ['French', 'Haitian'], + population: 11078033, + flag: 'https://restcountries.eu/data/hti.svg', + currency: 'Haitian gourde' + }, + { + name: 'Heard Island and McDonald Islands', + capital: '', + languages: ['English'], + population: 0, + flag: 'https://restcountries.eu/data/hmd.svg', + currency: 'Australian dollar' + }, + { + name: 'Holy See', + capital: 'Rome', + languages: ['Latin', 'Italian', 'French', 'German'], + population: 451, + flag: 'https://restcountries.eu/data/vat.svg', + currency: 'Euro' + }, + { + name: 'Honduras', + capital: 'Tegucigalpa', + languages: ['Spanish'], + population: 8576532, + flag: 'https://restcountries.eu/data/hnd.svg', + currency: 'Honduran lempira' + }, + { + name: 'Hong Kong', + capital: 'City of Victoria', + languages: ['English', 'Chinese'], + population: 7324300, + flag: 'https://restcountries.eu/data/hkg.svg', + currency: 'Hong Kong dollar' + }, + { + name: 'Hungary', + capital: 'Budapest', + languages: ['Hungarian'], + population: 9823000, + flag: 'https://restcountries.eu/data/hun.svg', + currency: 'Hungarian forint' + }, + { + name: 'Iceland', + capital: 'Reykjavík', + languages: ['Icelandic'], + population: 334300, + flag: 'https://restcountries.eu/data/isl.svg', + currency: 'Icelandic króna' + }, + { + name: 'India', + capital: 'New Delhi', + languages: ['Hindi', 'English'], + population: 1295210000, + flag: 'https://restcountries.eu/data/ind.svg', + currency: 'Indian rupee' + }, + { + name: 'Indonesia', + capital: 'Jakarta', + languages: ['Indonesian'], + population: 258705000, + flag: 'https://restcountries.eu/data/idn.svg', + currency: 'Indonesian rupiah' + }, + { + name: "Côte d'Ivoire", + capital: 'Yamoussoukro', + languages: ['French'], + population: 22671331, + flag: 'https://restcountries.eu/data/civ.svg', + currency: 'West African CFA franc' + }, + { + name: 'Iran (Islamic Republic of)', + capital: 'Tehran', + languages: ['Persian (Farsi)'], + population: 79369900, + flag: 'https://restcountries.eu/data/irn.svg', + currency: 'Iranian rial' + }, + { + name: 'Iraq', + capital: 'Baghdad', + languages: ['Arabic', 'Kurdish'], + population: 37883543, + flag: 'https://restcountries.eu/data/irq.svg', + currency: 'Iraqi dinar' + }, + { + name: 'Ireland', + capital: 'Dublin', + languages: ['Irish', 'English'], + population: 6378000, + flag: 'https://restcountries.eu/data/irl.svg', + currency: 'Euro' + }, + { + name: 'Isle of Man', + capital: 'Douglas', + languages: ['English', 'Manx'], + population: 84497, + flag: 'https://restcountries.eu/data/imn.svg', + currency: 'British pound' + }, + { + name: 'Israel', + capital: 'Jerusalem', + languages: ['Hebrew (modern)', 'Arabic'], + population: 8527400, + flag: 'https://restcountries.eu/data/isr.svg', + currency: 'Israeli new shekel' + }, + { + name: 'Italy', + capital: 'Rome', + languages: ['Italian'], + population: 60665551, + flag: 'https://restcountries.eu/data/ita.svg', + currency: 'Euro' + }, + { + name: 'Jamaica', + capital: 'Kingston', + languages: ['English'], + population: 2723246, + flag: 'https://restcountries.eu/data/jam.svg', + currency: 'Jamaican dollar' + }, + { + name: 'Japan', + capital: 'Tokyo', + languages: ['Japanese'], + population: 126960000, + flag: 'https://restcountries.eu/data/jpn.svg', + currency: 'Japanese yen' + }, + { + name: 'Jersey', + capital: 'Saint Helier', + languages: ['English', 'French'], + population: 100800, + flag: 'https://restcountries.eu/data/jey.svg', + currency: 'British pound' + }, + { + name: 'Jordan', + capital: 'Amman', + languages: ['Arabic'], + population: 9531712, + flag: 'https://restcountries.eu/data/jor.svg', + currency: 'Jordanian dinar' + }, + { + name: 'Kazakhstan', + capital: 'Astana', + languages: ['Kazakh', 'Russian'], + population: 17753200, + flag: 'https://restcountries.eu/data/kaz.svg', + currency: 'Kazakhstani tenge' + }, + { + name: 'Kenya', + capital: 'Nairobi', + languages: ['English', 'Swahili'], + population: 47251000, + flag: 'https://restcountries.eu/data/ken.svg', + currency: 'Kenyan shilling' + }, + { + name: 'Kiribati', + capital: 'South Tarawa', + languages: ['English'], + population: 113400, + flag: 'https://restcountries.eu/data/kir.svg', + currency: 'Australian dollar' + }, + { + name: 'Kuwait', + capital: 'Kuwait City', + languages: ['Arabic'], + population: 4183658, + flag: 'https://restcountries.eu/data/kwt.svg', + currency: 'Kuwaiti dinar' + }, + { + name: 'Kyrgyzstan', + capital: 'Bishkek', + languages: ['Kyrgyz', 'Russian'], + population: 6047800, + flag: 'https://restcountries.eu/data/kgz.svg', + currency: 'Kyrgyzstani som' + }, + { + name: "Lao People's Democratic Republic", + capital: 'Vientiane', + languages: ['Lao'], + population: 6492400, + flag: 'https://restcountries.eu/data/lao.svg', + currency: 'Lao kip' + }, + { + name: 'Latvia', + capital: 'Riga', + languages: ['Latvian'], + population: 1961600, + flag: 'https://restcountries.eu/data/lva.svg', + currency: 'Euro' + }, + { + name: 'Lebanon', + capital: 'Beirut', + languages: ['Arabic', 'French'], + population: 5988000, + flag: 'https://restcountries.eu/data/lbn.svg', + currency: 'Lebanese pound' + }, + { + name: 'Lesotho', + capital: 'Maseru', + languages: ['English', 'Southern Sotho'], + population: 1894194, + flag: 'https://restcountries.eu/data/lso.svg', + currency: 'Lesotho loti' + }, + { + name: 'Liberia', + capital: 'Monrovia', + languages: ['English'], + population: 4615000, + flag: 'https://restcountries.eu/data/lbr.svg', + currency: 'Liberian dollar' + }, + { + name: 'Libya', + capital: 'Tripoli', + languages: ['Arabic'], + population: 6385000, + flag: 'https://restcountries.eu/data/lby.svg', + currency: 'Libyan dinar' + }, + { + name: 'Liechtenstein', + capital: 'Vaduz', + languages: ['German'], + population: 37623, + flag: 'https://restcountries.eu/data/lie.svg', + currency: 'Swiss franc' + }, + { + name: 'Lithuania', + capital: 'Vilnius', + languages: ['Lithuanian'], + population: 2872294, + flag: 'https://restcountries.eu/data/ltu.svg', + currency: 'Euro' + }, + { + name: 'Luxembourg', + capital: 'Luxembourg', + languages: ['French', 'German', 'Luxembourgish'], + population: 576200, + flag: 'https://restcountries.eu/data/lux.svg', + currency: 'Euro' + }, + { + name: 'Macao', + capital: '', + languages: ['Chinese', 'Portuguese'], + population: 649100, + flag: 'https://restcountries.eu/data/mac.svg', + currency: 'Macanese pataca' + }, + { + name: 'Macedonia (the former Yugoslav Republic of)', + capital: 'Skopje', + languages: ['Macedonian'], + population: 2058539, + flag: 'https://restcountries.eu/data/mkd.svg', + currency: 'Macedonian denar' + }, + { + name: 'Madagascar', + capital: 'Antananarivo', + languages: ['French', 'Malagasy'], + population: 22434363, + flag: 'https://restcountries.eu/data/mdg.svg', + currency: 'Malagasy ariary' + }, + { + name: 'Malawi', + capital: 'Lilongwe', + languages: ['English', 'Chichewa'], + population: 16832910, + flag: 'https://restcountries.eu/data/mwi.svg', + currency: 'Malawian kwacha' + }, + { + name: 'Malaysia', + capital: 'Kuala Lumpur', + languages: ['Malaysian'], + population: 31405416, + flag: 'https://restcountries.eu/data/mys.svg', + currency: 'Malaysian ringgit' + }, + { + name: 'Maldives', + capital: 'Malé', + languages: ['Divehi'], + population: 344023, + flag: 'https://restcountries.eu/data/mdv.svg', + currency: 'Maldivian rufiyaa' + }, + { + name: 'Mali', + capital: 'Bamako', + languages: ['French'], + population: 18135000, + flag: 'https://restcountries.eu/data/mli.svg', + currency: 'West African CFA franc' + }, + { + name: 'Malta', + capital: 'Valletta', + languages: ['Maltese', 'English'], + population: 425384, + flag: 'https://restcountries.eu/data/mlt.svg', + currency: 'Euro' + }, + { + name: 'Marshall Islands', + capital: 'Majuro', + languages: ['English', 'Marshallese'], + population: 54880, + flag: 'https://restcountries.eu/data/mhl.svg', + currency: 'United States dollar' + }, + { + name: 'Martinique', + capital: 'Fort-de-France', + languages: ['French'], + population: 378243, + flag: 'https://restcountries.eu/data/mtq.svg', + currency: 'Euro' + }, + { + name: 'Mauritania', + capital: 'Nouakchott', + languages: ['Arabic'], + population: 3718678, + flag: 'https://restcountries.eu/data/mrt.svg', + currency: 'Mauritanian ouguiya' + }, + { + name: 'Mauritius', + capital: 'Port Louis', + languages: ['English'], + population: 1262879, + flag: 'https://restcountries.eu/data/mus.svg', + currency: 'Mauritian rupee' + }, + { + name: 'Mayotte', + capital: 'Mamoudzou', + languages: ['French'], + population: 226915, + flag: 'https://restcountries.eu/data/myt.svg', + currency: 'Euro' + }, + { + name: 'Mexico', + capital: 'Mexico City', + languages: ['Spanish'], + population: 122273473, + flag: 'https://restcountries.eu/data/mex.svg', + currency: 'Mexican peso' + }, + { + name: 'Micronesia (Federated States of)', + capital: 'Palikir', + languages: ['English'], + population: 102800, + flag: 'https://restcountries.eu/data/fsm.svg', + currency: '[D]' + }, + { + name: 'Moldova (Republic of)', + capital: 'Chișinău', + languages: ['Romanian'], + population: 3553100, + flag: 'https://restcountries.eu/data/mda.svg', + currency: 'Moldovan leu' + }, + { + name: 'Monaco', + capital: 'Monaco', + languages: ['French'], + population: 38400, + flag: 'https://restcountries.eu/data/mco.svg', + currency: 'Euro' + }, + { + name: 'Mongolia', + capital: 'Ulan Bator', + languages: ['Mongolian'], + population: 3093100, + flag: 'https://restcountries.eu/data/mng.svg', + currency: 'Mongolian tögrög' + }, + { + name: 'Montenegro', + capital: 'Podgorica', + languages: ['Serbian', 'Bosnian', 'Albanian', 'Croatian'], + population: 621810, + flag: 'https://restcountries.eu/data/mne.svg', + currency: 'Euro' + }, + { + name: 'Montserrat', + capital: 'Plymouth', + languages: ['English'], + population: 4922, + flag: 'https://restcountries.eu/data/msr.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Morocco', + capital: 'Rabat', + languages: ['Arabic'], + population: 33337529, + flag: 'https://restcountries.eu/data/mar.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Mozambique', + capital: 'Maputo', + languages: ['Portuguese'], + population: 26423700, + flag: 'https://restcountries.eu/data/moz.svg', + currency: 'Mozambican metical' + }, + { + name: 'Myanmar', + capital: 'Naypyidaw', + languages: ['Burmese'], + population: 51419420, + flag: 'https://restcountries.eu/data/mmr.svg', + currency: 'Burmese kyat' + }, + { + name: 'Namibia', + capital: 'Windhoek', + languages: ['English', 'Afrikaans'], + population: 2324388, + flag: 'https://restcountries.eu/data/nam.svg', + currency: 'Namibian dollar' + }, + { + name: 'Nauru', + capital: 'Yaren', + languages: ['English', 'Nauruan'], + population: 10084, + flag: 'https://restcountries.eu/data/nru.svg', + currency: 'Australian dollar' + }, + { + name: 'Nepal', + capital: 'Kathmandu', + languages: ['Nepali'], + population: 28431500, + flag: 'https://restcountries.eu/data/npl.svg', + currency: 'Nepalese rupee' + }, + { + name: 'Netherlands', + capital: 'Amsterdam', + languages: ['Dutch'], + population: 17019800, + flag: 'https://restcountries.eu/data/nld.svg', + currency: 'Euro' + }, + { + name: 'New Caledonia', + capital: 'Nouméa', + languages: ['French'], + population: 268767, + flag: 'https://restcountries.eu/data/ncl.svg', + currency: 'CFP franc' + }, + { + name: 'New Zealand', + capital: 'Wellington', + languages: ['English', 'Māori'], + population: 4697854, + flag: 'https://restcountries.eu/data/nzl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Nicaragua', + capital: 'Managua', + languages: ['Spanish'], + population: 6262703, + flag: 'https://restcountries.eu/data/nic.svg', + currency: 'Nicaraguan córdoba' + }, + { + name: 'Niger', + capital: 'Niamey', + languages: ['French'], + population: 20715000, + flag: 'https://restcountries.eu/data/ner.svg', + currency: 'West African CFA franc' + }, + { + name: 'Nigeria', + capital: 'Abuja', + languages: ['English'], + population: 186988000, + flag: 'https://restcountries.eu/data/nga.svg', + currency: 'Nigerian naira' + }, + { + name: 'Niue', + capital: 'Alofi', + languages: ['English'], + population: 1470, + flag: 'https://restcountries.eu/data/niu.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Norfolk Island', + capital: 'Kingston', + languages: ['English'], + population: 2302, + flag: 'https://restcountries.eu/data/nfk.svg', + currency: 'Australian dollar' + }, + { + name: "Korea (Democratic People's Republic of)", + capital: 'Pyongyang', + languages: ['Korean'], + population: 25281000, + flag: 'https://restcountries.eu/data/prk.svg', + currency: 'North Korean won' + }, + { + name: 'Northern Mariana Islands', + capital: 'Saipan', + languages: ['English', 'Chamorro'], + population: 56940, + flag: 'https://restcountries.eu/data/mnp.svg', + currency: 'United States dollar' + }, + { + name: 'Norway', + capital: 'Oslo', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 5223256, + flag: 'https://restcountries.eu/data/nor.svg', + currency: 'Norwegian krone' + }, + { + name: 'Oman', + capital: 'Muscat', + languages: ['Arabic'], + population: 4420133, + flag: 'https://restcountries.eu/data/omn.svg', + currency: 'Omani rial' + }, + { + name: 'Pakistan', + capital: 'Islamabad', + languages: ['English', 'Urdu'], + population: 194125062, + flag: 'https://restcountries.eu/data/pak.svg', + currency: 'Pakistani rupee' + }, + { + name: 'Palau', + capital: 'Ngerulmud', + languages: ['English'], + population: 17950, + flag: 'https://restcountries.eu/data/plw.svg', + currency: '[E]' + }, + { + name: 'Palestine, State of', + capital: 'Ramallah', + languages: ['Arabic'], + population: 4682467, + flag: 'https://restcountries.eu/data/pse.svg', + currency: 'Israeli new sheqel' + }, + { + name: 'Panama', + capital: 'Panama City', + languages: ['Spanish'], + population: 3814672, + flag: 'https://restcountries.eu/data/pan.svg', + currency: 'Panamanian balboa' + }, + { + name: 'Papua New Guinea', + capital: 'Port Moresby', + languages: ['English'], + population: 8083700, + flag: 'https://restcountries.eu/data/png.svg', + currency: 'Papua New Guinean kina' + }, + { + name: 'Paraguay', + capital: 'Asunción', + languages: ['Spanish', 'Guaraní'], + population: 6854536, + flag: 'https://restcountries.eu/data/pry.svg', + currency: 'Paraguayan guaraní' + }, + { + name: 'Peru', + capital: 'Lima', + languages: ['Spanish'], + population: 31488700, + flag: 'https://restcountries.eu/data/per.svg', + currency: 'Peruvian sol' + }, + { + name: 'Philippines', + capital: 'Manila', + languages: ['English'], + population: 103279800, + flag: 'https://restcountries.eu/data/phl.svg', + currency: 'Philippine peso' + }, + { + name: 'Pitcairn', + capital: 'Adamstown', + languages: ['English'], + population: 56, + flag: 'https://restcountries.eu/data/pcn.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Poland', + capital: 'Warsaw', + languages: ['Polish'], + population: 38437239, + flag: 'https://restcountries.eu/data/pol.svg', + currency: 'Polish złoty' + }, + { + name: 'Portugal', + capital: 'Lisbon', + languages: ['Portuguese'], + population: 10374822, + flag: 'https://restcountries.eu/data/prt.svg', + currency: 'Euro' + }, + { + name: 'Puerto Rico', + capital: 'San Juan', + languages: ['Spanish', 'English'], + population: 3474182, + flag: 'https://restcountries.eu/data/pri.svg', + currency: 'United States dollar' + }, + { + name: 'Qatar', + capital: 'Doha', + languages: ['Arabic'], + population: 2587564, + flag: 'https://restcountries.eu/data/qat.svg', + currency: 'Qatari riyal' + }, + { + name: 'Republic of Kosovo', + capital: 'Pristina', + languages: ['Albanian', 'Serbian'], + population: 1733842, + flag: 'https://restcountries.eu/data/kos.svg', + currency: 'Euro' + }, + { + name: 'Réunion', + capital: 'Saint-Denis', + languages: ['French'], + population: 840974, + flag: 'https://restcountries.eu/data/reu.svg', + currency: 'Euro' + }, + { + name: 'Romania', + capital: 'Bucharest', + languages: ['Romanian'], + population: 19861408, + flag: 'https://restcountries.eu/data/rou.svg', + currency: 'Romanian leu' + }, + { + name: 'Russian Federation', + capital: 'Moscow', + languages: ['Russian'], + population: 146599183, + flag: 'https://restcountries.eu/data/rus.svg', + currency: 'Russian ruble' + }, + { + name: 'Rwanda', + capital: 'Kigali', + languages: ['Kinyarwanda', 'English', 'French'], + population: 11553188, + flag: 'https://restcountries.eu/data/rwa.svg', + currency: 'Rwandan franc' + }, + { + name: 'Saint Barthélemy', + capital: 'Gustavia', + languages: ['French'], + population: 9417, + flag: 'https://restcountries.eu/data/blm.svg', + currency: 'Euro' + }, + { + name: 'Saint Helena, Ascension and Tristan da Cunha', + capital: 'Jamestown', + languages: ['English'], + population: 4255, + flag: 'https://restcountries.eu/data/shn.svg', + currency: 'Saint Helena pound' + }, + { + name: 'Saint Kitts and Nevis', + capital: 'Basseterre', + languages: ['English'], + population: 46204, + flag: 'https://restcountries.eu/data/kna.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Lucia', + capital: 'Castries', + languages: ['English'], + population: 186000, + flag: 'https://restcountries.eu/data/lca.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Martin (French part)', + capital: 'Marigot', + languages: ['English', 'French', 'Dutch'], + population: 36979, + flag: 'https://restcountries.eu/data/maf.svg', + currency: 'Euro' + }, + { + name: 'Saint Pierre and Miquelon', + capital: 'Saint-Pierre', + languages: ['French'], + population: 6069, + flag: 'https://restcountries.eu/data/spm.svg', + currency: 'Euro' + }, + { + name: 'Saint Vincent and the Grenadines', + capital: 'Kingstown', + languages: ['English'], + population: 109991, + flag: 'https://restcountries.eu/data/vct.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Samoa', + capital: 'Apia', + languages: ['Samoan', 'English'], + population: 194899, + flag: 'https://restcountries.eu/data/wsm.svg', + currency: 'Samoan tālā' + }, + { + name: 'San Marino', + capital: 'City of San Marino', + languages: ['Italian'], + population: 33005, + flag: 'https://restcountries.eu/data/smr.svg', + currency: 'Euro' + }, + { + name: 'Sao Tome and Principe', + capital: 'São Tomé', + languages: ['Portuguese'], + population: 187356, + flag: 'https://restcountries.eu/data/stp.svg', + currency: 'São Tomé and Príncipe dobra' + }, + { + name: 'Saudi Arabia', + capital: 'Riyadh', + languages: ['Arabic'], + population: 32248200, + flag: 'https://restcountries.eu/data/sau.svg', + currency: 'Saudi riyal' + }, + { + name: 'Senegal', + capital: 'Dakar', + languages: ['French'], + population: 14799859, + flag: 'https://restcountries.eu/data/sen.svg', + currency: 'West African CFA franc' + }, + { + name: 'Serbia', + capital: 'Belgrade', + languages: ['Serbian'], + population: 7076372, + flag: 'https://restcountries.eu/data/srb.svg', + currency: 'Serbian dinar' + }, + { + name: 'Seychelles', + capital: 'Victoria', + languages: ['French', 'English'], + population: 91400, + flag: 'https://restcountries.eu/data/syc.svg', + currency: 'Seychellois rupee' + }, + { + name: 'Sierra Leone', + capital: 'Freetown', + languages: ['English'], + population: 7075641, + flag: 'https://restcountries.eu/data/sle.svg', + currency: 'Sierra Leonean leone' + }, + { + name: 'Singapore', + capital: 'Singapore', + languages: ['English', 'Malay', 'Tamil', 'Chinese'], + population: 5535000, + flag: 'https://restcountries.eu/data/sgp.svg', + currency: 'Brunei dollar' + }, + { + name: 'Sint Maarten (Dutch part)', + capital: 'Philipsburg', + languages: ['Dutch', 'English'], + population: 38247, + flag: 'https://restcountries.eu/data/sxm.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Slovakia', + capital: 'Bratislava', + languages: ['Slovak'], + population: 5426252, + flag: 'https://restcountries.eu/data/svk.svg', + currency: 'Euro' + }, + { + name: 'Slovenia', + capital: 'Ljubljana', + languages: ['Slovene'], + population: 2064188, + flag: 'https://restcountries.eu/data/svn.svg', + currency: 'Euro' + }, + { + name: 'Solomon Islands', + capital: 'Honiara', + languages: ['English'], + population: 642000, + flag: 'https://restcountries.eu/data/slb.svg', + currency: 'Solomon Islands dollar' + }, + { + name: 'Somalia', + capital: 'Mogadishu', + languages: ['Somali', 'Arabic'], + population: 11079000, + flag: 'https://restcountries.eu/data/som.svg', + currency: 'Somali shilling' + }, + { + name: 'South Africa', + capital: 'Pretoria', + languages: [ + 'Afrikaans', + 'English', + 'Southern Ndebele', + 'Southern Sotho', + 'Swati', + 'Tswana', + 'Tsonga', + 'Venda', + 'Xhosa', + 'Zulu' + ], + population: 55653654, + flag: 'https://restcountries.eu/data/zaf.svg', + currency: 'South African rand' + }, + { + name: 'South Georgia and the South Sandwich Islands', + capital: 'King Edward Point', + languages: ['English'], + population: 30, + flag: 'https://restcountries.eu/data/sgs.svg', + currency: 'British pound' + }, + { + name: 'Korea (Republic of)', + capital: 'Seoul', + languages: ['Korean'], + population: 50801405, + flag: 'https://restcountries.eu/data/kor.svg', + currency: 'South Korean won' + }, + { + name: 'South Sudan', + capital: 'Juba', + languages: ['English'], + population: 12131000, + flag: 'https://restcountries.eu/data/ssd.svg', + currency: 'South Sudanese pound' + }, + { + name: 'Spain', + capital: 'Madrid', + languages: ['Spanish'], + population: 46438422, + flag: 'https://restcountries.eu/data/esp.svg', + currency: 'Euro' + }, + { + name: 'Sri Lanka', + capital: 'Colombo', + languages: ['Sinhalese', 'Tamil'], + population: 20966000, + flag: 'https://restcountries.eu/data/lka.svg', + currency: 'Sri Lankan rupee' + }, + { + name: 'Sudan', + capital: 'Khartoum', + languages: ['Arabic', 'English'], + population: 39598700, + flag: 'https://restcountries.eu/data/sdn.svg', + currency: 'Sudanese pound' + }, + { + name: 'Suriname', + capital: 'Paramaribo', + languages: ['Dutch'], + population: 541638, + flag: 'https://restcountries.eu/data/sur.svg', + currency: 'Surinamese dollar' + }, + { + name: 'Svalbard and Jan Mayen', + capital: 'Longyearbyen', + languages: ['Norwegian'], + population: 2562, + flag: 'https://restcountries.eu/data/sjm.svg', + currency: 'Norwegian krone' + }, + { + name: 'Swaziland', + capital: 'Lobamba', + languages: ['English', 'Swati'], + population: 1132657, + flag: 'https://restcountries.eu/data/swz.svg', + currency: 'Swazi lilangeni' + }, + { + name: 'Sweden', + capital: 'Stockholm', + languages: ['Swedish'], + population: 9894888, + flag: 'https://restcountries.eu/data/swe.svg', + currency: 'Swedish krona' + }, + { + name: 'Switzerland', + capital: 'Bern', + languages: ['German', 'French', 'Italian'], + population: 8341600, + flag: 'https://restcountries.eu/data/che.svg', + currency: 'Swiss franc' + }, + { + name: 'Syrian Arab Republic', + capital: 'Damascus', + languages: ['Arabic'], + population: 18564000, + flag: 'https://restcountries.eu/data/syr.svg', + currency: 'Syrian pound' + }, + { + name: 'Taiwan', + capital: 'Taipei', + languages: ['Chinese'], + population: 23503349, + flag: 'https://restcountries.eu/data/twn.svg', + currency: 'New Taiwan dollar' + }, + { + name: 'Tajikistan', + capital: 'Dushanbe', + languages: ['Tajik', 'Russian'], + population: 8593600, + flag: 'https://restcountries.eu/data/tjk.svg', + currency: 'Tajikistani somoni' + }, + { + name: 'Tanzania, United Republic of', + capital: 'Dodoma', + languages: ['Swahili', 'English'], + population: 55155000, + flag: 'https://restcountries.eu/data/tza.svg', + currency: 'Tanzanian shilling' + }, + { + name: 'Thailand', + capital: 'Bangkok', + languages: ['Thai'], + population: 65327652, + flag: 'https://restcountries.eu/data/tha.svg', + currency: 'Thai baht' + }, + { + name: 'Timor-Leste', + capital: 'Dili', + languages: ['Portuguese'], + population: 1167242, + flag: 'https://restcountries.eu/data/tls.svg', + currency: 'United States dollar' + }, + { + name: 'Togo', + capital: 'Lomé', + languages: ['French'], + population: 7143000, + flag: 'https://restcountries.eu/data/tgo.svg', + currency: 'West African CFA franc' + }, + { + name: 'Tokelau', + capital: 'Fakaofo', + languages: ['English'], + population: 1411, + flag: 'https://restcountries.eu/data/tkl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Tonga', + capital: "Nuku'alofa", + languages: ['English', 'Tonga (Tonga Islands)'], + population: 103252, + flag: 'https://restcountries.eu/data/ton.svg', + currency: 'Tongan paʻanga' + }, + { + name: 'Trinidad and Tobago', + capital: 'Port of Spain', + languages: ['English'], + population: 1349667, + flag: 'https://restcountries.eu/data/tto.svg', + currency: 'Trinidad and Tobago dollar' + }, + { + name: 'Tunisia', + capital: 'Tunis', + languages: ['Arabic'], + population: 11154400, + flag: 'https://restcountries.eu/data/tun.svg', + currency: 'Tunisian dinar' + }, + { + name: 'Turkey', + capital: 'Ankara', + languages: ['Turkish'], + population: 78741053, + flag: 'https://restcountries.eu/data/tur.svg', + currency: 'Turkish lira' + }, + { + name: 'Turkmenistan', + capital: 'Ashgabat', + languages: ['Turkmen', 'Russian'], + population: 4751120, + flag: 'https://restcountries.eu/data/tkm.svg', + currency: 'Turkmenistan manat' + }, + { + name: 'Turks and Caicos Islands', + capital: 'Cockburn Town', + languages: ['English'], + population: 31458, + flag: 'https://restcountries.eu/data/tca.svg', + currency: 'United States dollar' + }, + { + name: 'Tuvalu', + capital: 'Funafuti', + languages: ['English'], + population: 10640, + flag: 'https://restcountries.eu/data/tuv.svg', + currency: 'Australian dollar' + }, + { + name: 'Uganda', + capital: 'Kampala', + languages: ['English', 'Swahili'], + population: 33860700, + flag: 'https://restcountries.eu/data/uga.svg', + currency: 'Ugandan shilling' + }, + { + name: 'Ukraine', + capital: 'Kiev', + languages: ['Ukrainian'], + population: 42692393, + flag: 'https://restcountries.eu/data/ukr.svg', + currency: 'Ukrainian hryvnia' + }, + { + name: 'United Arab Emirates', + capital: 'Abu Dhabi', + languages: ['Arabic'], + population: 9856000, + flag: 'https://restcountries.eu/data/are.svg', + currency: 'United Arab Emirates dirham' + }, + { + name: 'United Kingdom of Great Britain and Northern Ireland', + capital: 'London', + languages: ['English'], + population: 65110000, + flag: 'https://restcountries.eu/data/gbr.svg', + currency: 'British pound' + }, + { + name: 'United States of America', + capital: 'Washington, D.C.', + languages: ['English'], + population: 323947000, + flag: 'https://restcountries.eu/data/usa.svg', + currency: 'United States dollar' + }, + { + name: 'Uruguay', + capital: 'Montevideo', + languages: ['Spanish'], + population: 3480222, + flag: 'https://restcountries.eu/data/ury.svg', + currency: 'Uruguayan peso' + }, + { + name: 'Uzbekistan', + capital: 'Tashkent', + languages: ['Uzbek', 'Russian'], + population: 31576400, + flag: 'https://restcountries.eu/data/uzb.svg', + currency: "Uzbekistani so'm" + }, + { + name: 'Vanuatu', + capital: 'Port Vila', + languages: ['Bislama', 'English', 'French'], + population: 277500, + flag: 'https://restcountries.eu/data/vut.svg', + currency: 'Vanuatu vatu' + }, + { + name: 'Venezuela (Bolivarian Republic of)', + capital: 'Caracas', + languages: ['Spanish'], + population: 31028700, + flag: 'https://restcountries.eu/data/ven.svg', + currency: 'Venezuelan bolívar' + }, + { + name: 'Viet Nam', + capital: 'Hanoi', + languages: ['Vietnamese'], + population: 92700000, + flag: 'https://restcountries.eu/data/vnm.svg', + currency: 'Vietnamese đồng' + }, + { + name: 'Wallis and Futuna', + capital: 'Mata-Utu', + languages: ['French'], + population: 11750, + flag: 'https://restcountries.eu/data/wlf.svg', + currency: 'CFP franc' + }, + { + name: 'Western Sahara', + capital: 'El Aaiún', + languages: ['Spanish'], + population: 510713, + flag: 'https://restcountries.eu/data/esh.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Yemen', + capital: "Sana'a", + languages: ['Arabic'], + population: 27478000, + flag: 'https://restcountries.eu/data/yem.svg', + currency: 'Yemeni rial' + }, + { + name: 'Zambia', + capital: 'Lusaka', + languages: ['English'], + population: 15933883, + flag: 'https://restcountries.eu/data/zmb.svg', + currency: 'Zambian kwacha' + }, + { + name: 'Zimbabwe', + capital: 'Harare', + languages: ['English', 'Shona', 'Northern Ndebele'], + population: 14240168, + flag: 'https://restcountries.eu/data/zwe.svg', + currency: 'Botswana pula' + } +] diff --git a/19_Day_Closures/19_day_starter/index.html b/19_Day_Closures/19_day_starter/index.html new file mode 100644 index 0000000..a72d694 --- /dev/null +++ b/19_Day_Closures/19_day_starter/index.html @@ -0,0 +1,17 @@ + + + + + 30DaysOfJavaScript:19 Day + + + +

30DaysOfJavaScript:19 Day

+

Writing Clean Code

+ + + + + + + \ No newline at end of file diff --git a/19_Day_Closures/19_day_starter/scripts/main.js b/19_Day_Closures/19_day_starter/scripts/main.js new file mode 100644 index 0000000..c6045c8 --- /dev/null +++ b/19_Day_Closures/19_day_starter/scripts/main.js @@ -0,0 +1,2 @@ +console.log(countries) +alert('Open the console and check if the countries has been loaded') \ No newline at end of file diff --git a/20_Day_Writing_clean_codes/20_day_starter/data/countries_data.js b/20_Day_Writing_clean_codes/20_day_starter/data/countries_data.js new file mode 100644 index 0000000..92acddd --- /dev/null +++ b/20_Day_Writing_clean_codes/20_day_starter/data/countries_data.js @@ -0,0 +1,2013 @@ +const countries = [ + { + name: 'Afghanistan', + capital: 'Kabul', + languages: ['Pashto', 'Uzbek', 'Turkmen'], + population: 27657145, + flag: 'https://restcountries.eu/data/afg.svg', + currency: 'Afghan afghani' + }, + { + name: 'Åland Islands', + capital: 'Mariehamn', + languages: ['Swedish'], + population: 28875, + flag: 'https://restcountries.eu/data/ala.svg', + currency: 'Euro' + }, + { + name: 'Albania', + capital: 'Tirana', + languages: ['Albanian'], + population: 2886026, + flag: 'https://restcountries.eu/data/alb.svg', + currency: 'Albanian lek' + }, + { + name: 'Algeria', + capital: 'Algiers', + languages: ['Arabic'], + population: 40400000, + flag: 'https://restcountries.eu/data/dza.svg', + currency: 'Algerian dinar' + }, + { + name: 'American Samoa', + capital: 'Pago Pago', + languages: ['English', 'Samoan'], + population: 57100, + flag: 'https://restcountries.eu/data/asm.svg', + currency: 'United State Dollar' + }, + { + name: 'Andorra', + capital: 'Andorra la Vella', + languages: ['Catalan'], + population: 78014, + flag: 'https://restcountries.eu/data/and.svg', + currency: 'Euro' + }, + { + name: 'Angola', + capital: 'Luanda', + languages: ['Portuguese'], + population: 25868000, + flag: 'https://restcountries.eu/data/ago.svg', + currency: 'Angolan kwanza' + }, + { + name: 'Anguilla', + capital: 'The Valley', + languages: ['English'], + population: 13452, + flag: 'https://restcountries.eu/data/aia.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Antarctica', + capital: '', + languages: ['English', 'Russian'], + population: 1000, + flag: 'https://restcountries.eu/data/ata.svg', + currency: 'Australian dollar' + }, + { + name: 'Antigua and Barbuda', + capital: "Saint John's", + languages: ['English'], + population: 86295, + flag: 'https://restcountries.eu/data/atg.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Argentina', + capital: 'Buenos Aires', + languages: ['Spanish', 'Guaraní'], + population: 43590400, + flag: 'https://restcountries.eu/data/arg.svg', + currency: 'Argentine peso' + }, + { + name: 'Armenia', + capital: 'Yerevan', + languages: ['Armenian', 'Russian'], + population: 2994400, + flag: 'https://restcountries.eu/data/arm.svg', + currency: 'Armenian dram' + }, + { + name: 'Aruba', + capital: 'Oranjestad', + languages: ['Dutch', '(Eastern) Punjabi'], + population: 107394, + flag: 'https://restcountries.eu/data/abw.svg', + currency: 'Aruban florin' + }, + { + name: 'Australia', + capital: 'Canberra', + languages: ['English'], + population: 24117360, + flag: 'https://restcountries.eu/data/aus.svg', + currency: 'Australian dollar' + }, + { + name: 'Austria', + capital: 'Vienna', + languages: ['German'], + population: 8725931, + flag: 'https://restcountries.eu/data/aut.svg', + currency: 'Euro' + }, + { + name: 'Azerbaijan', + capital: 'Baku', + languages: ['Azerbaijani'], + population: 9730500, + flag: 'https://restcountries.eu/data/aze.svg', + currency: 'Azerbaijani manat' + }, + { + name: 'Bahamas', + capital: 'Nassau', + languages: ['English'], + population: 378040, + flag: 'https://restcountries.eu/data/bhs.svg', + currency: 'Bahamian dollar' + }, + { + name: 'Bahrain', + capital: 'Manama', + languages: ['Arabic'], + population: 1404900, + flag: 'https://restcountries.eu/data/bhr.svg', + currency: 'Bahraini dinar' + }, + { + name: 'Bangladesh', + capital: 'Dhaka', + languages: ['Bengali'], + population: 161006790, + flag: 'https://restcountries.eu/data/bgd.svg', + currency: 'Bangladeshi taka' + }, + { + name: 'Barbados', + capital: 'Bridgetown', + languages: ['English'], + population: 285000, + flag: 'https://restcountries.eu/data/brb.svg', + currency: 'Barbadian dollar' + }, + { + name: 'Belarus', + capital: 'Minsk', + languages: ['Belarusian', 'Russian'], + population: 9498700, + flag: 'https://restcountries.eu/data/blr.svg', + currency: 'New Belarusian ruble' + }, + { + name: 'Belgium', + capital: 'Brussels', + languages: ['Dutch', 'French', 'German'], + population: 11319511, + flag: 'https://restcountries.eu/data/bel.svg', + currency: 'Euro' + }, + { + name: 'Belize', + capital: 'Belmopan', + languages: ['English', 'Spanish'], + population: 370300, + flag: 'https://restcountries.eu/data/blz.svg', + currency: 'Belize dollar' + }, + { + name: 'Benin', + capital: 'Porto-Novo', + languages: ['French'], + population: 10653654, + flag: 'https://restcountries.eu/data/ben.svg', + currency: 'West African CFA franc' + }, + { + name: 'Bermuda', + capital: 'Hamilton', + languages: ['English'], + population: 61954, + flag: 'https://restcountries.eu/data/bmu.svg', + currency: 'Bermudian dollar' + }, + { + name: 'Bhutan', + capital: 'Thimphu', + languages: ['Dzongkha'], + population: 775620, + flag: 'https://restcountries.eu/data/btn.svg', + currency: 'Bhutanese ngultrum' + }, + { + name: 'Bolivia (Plurinational State of)', + capital: 'Sucre', + languages: ['Spanish', 'Aymara', 'Quechua'], + population: 10985059, + flag: 'https://restcountries.eu/data/bol.svg', + currency: 'Bolivian boliviano' + }, + { + name: 'Bonaire, Sint Eustatius and Saba', + capital: 'Kralendijk', + languages: ['Dutch'], + population: 17408, + flag: 'https://restcountries.eu/data/bes.svg', + currency: 'United States dollar' + }, + { + name: 'Bosnia and Herzegovina', + capital: 'Sarajevo', + languages: ['Bosnian', 'Croatian', 'Serbian'], + population: 3531159, + flag: 'https://restcountries.eu/data/bih.svg', + currency: 'Bosnia and Herzegovina convertible mark' + }, + { + name: 'Botswana', + capital: 'Gaborone', + languages: ['English', 'Tswana'], + population: 2141206, + flag: 'https://restcountries.eu/data/bwa.svg', + currency: 'Botswana pula' + }, + { + name: 'Bouvet Island', + capital: '', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 0, + flag: 'https://restcountries.eu/data/bvt.svg', + currency: 'Norwegian krone' + }, + { + name: 'Brazil', + capital: 'Brasília', + languages: ['Portuguese'], + population: 206135893, + flag: 'https://restcountries.eu/data/bra.svg', + currency: 'Brazilian real' + }, + { + name: 'British Indian Ocean Territory', + capital: 'Diego Garcia', + languages: ['English'], + population: 3000, + flag: 'https://restcountries.eu/data/iot.svg', + currency: 'United States dollar' + }, + { + name: 'United States Minor Outlying Islands', + capital: '', + languages: ['English'], + population: 300, + flag: 'https://restcountries.eu/data/umi.svg', + currency: 'United States Dollar' + }, + { + name: 'Virgin Islands (British)', + capital: 'Road Town', + languages: ['English'], + population: 28514, + flag: 'https://restcountries.eu/data/vgb.svg', + currency: '[D]' + }, + { + name: 'Virgin Islands (U.S.)', + capital: 'Charlotte Amalie', + languages: ['English'], + population: 114743, + flag: 'https://restcountries.eu/data/vir.svg', + currency: 'United States dollar' + }, + { + name: 'Brunei Darussalam', + capital: 'Bandar Seri Begawan', + languages: ['Malay'], + population: 411900, + flag: 'https://restcountries.eu/data/brn.svg', + currency: 'Brunei dollar' + }, + { + name: 'Bulgaria', + capital: 'Sofia', + languages: ['Bulgarian'], + population: 7153784, + flag: 'https://restcountries.eu/data/bgr.svg', + currency: 'Bulgarian lev' + }, + { + name: 'Burkina Faso', + capital: 'Ouagadougou', + languages: ['French', 'Fula'], + population: 19034397, + flag: 'https://restcountries.eu/data/bfa.svg', + currency: 'West African CFA franc' + }, + { + name: 'Burundi', + capital: 'Bujumbura', + languages: ['French', 'Kirundi'], + population: 10114505, + flag: 'https://restcountries.eu/data/bdi.svg', + currency: 'Burundian franc' + }, + { + name: 'Cambodia', + capital: 'Phnom Penh', + languages: ['Khmer'], + population: 15626444, + flag: 'https://restcountries.eu/data/khm.svg', + currency: 'Cambodian riel' + }, + { + name: 'Cameroon', + capital: 'Yaoundé', + languages: ['English', 'French'], + population: 22709892, + flag: 'https://restcountries.eu/data/cmr.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Canada', + capital: 'Ottawa', + languages: ['English', 'French'], + population: 36155487, + flag: 'https://restcountries.eu/data/can.svg', + currency: 'Canadian dollar' + }, + { + name: 'Cabo Verde', + capital: 'Praia', + languages: ['Portuguese'], + population: 531239, + flag: 'https://restcountries.eu/data/cpv.svg', + currency: 'Cape Verdean escudo' + }, + { + name: 'Cayman Islands', + capital: 'George Town', + languages: ['English'], + population: 58238, + flag: 'https://restcountries.eu/data/cym.svg', + currency: 'Cayman Islands dollar' + }, + { + name: 'Central African Republic', + capital: 'Bangui', + languages: ['French', 'Sango'], + population: 4998000, + flag: 'https://restcountries.eu/data/caf.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chad', + capital: "N'Djamena", + languages: ['French', 'Arabic'], + population: 14497000, + flag: 'https://restcountries.eu/data/tcd.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chile', + capital: 'Santiago', + languages: ['Spanish'], + population: 18191900, + flag: 'https://restcountries.eu/data/chl.svg', + currency: 'Chilean peso' + }, + { + name: 'China', + capital: 'Beijing', + languages: ['Chinese'], + population: 1377422166, + flag: 'https://restcountries.eu/data/chn.svg', + currency: 'Chinese yuan' + }, + { + name: 'Christmas Island', + capital: 'Flying Fish Cove', + languages: ['English'], + population: 2072, + flag: 'https://restcountries.eu/data/cxr.svg', + currency: 'Australian dollar' + }, + { + name: 'Cocos (Keeling) Islands', + capital: 'West Island', + languages: ['English'], + population: 550, + flag: 'https://restcountries.eu/data/cck.svg', + currency: 'Australian dollar' + }, + { + name: 'Colombia', + capital: 'Bogotá', + languages: ['Spanish'], + population: 48759958, + flag: 'https://restcountries.eu/data/col.svg', + currency: 'Colombian peso' + }, + { + name: 'Comoros', + capital: 'Moroni', + languages: ['Arabic', 'French'], + population: 806153, + flag: 'https://restcountries.eu/data/com.svg', + currency: 'Comorian franc' + }, + { + name: 'Congo', + capital: 'Brazzaville', + languages: ['French', 'Lingala'], + population: 4741000, + flag: 'https://restcountries.eu/data/cog.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Congo (Democratic Republic of the)', + capital: 'Kinshasa', + languages: ['French', 'Lingala', 'Kongo', 'Swahili', 'Luba-Katanga'], + population: 85026000, + flag: 'https://restcountries.eu/data/cod.svg', + currency: 'Congolese franc' + }, + { + name: 'Cook Islands', + capital: 'Avarua', + languages: ['English'], + population: 18100, + flag: 'https://restcountries.eu/data/cok.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Costa Rica', + capital: 'San José', + languages: ['Spanish'], + population: 4890379, + flag: 'https://restcountries.eu/data/cri.svg', + currency: 'Costa Rican colón' + }, + { + name: 'Croatia', + capital: 'Zagreb', + languages: ['Croatian'], + population: 4190669, + flag: 'https://restcountries.eu/data/hrv.svg', + currency: 'Croatian kuna' + }, + { + name: 'Cuba', + capital: 'Havana', + languages: ['Spanish'], + population: 11239004, + flag: 'https://restcountries.eu/data/cub.svg', + currency: 'Cuban convertible peso' + }, + { + name: 'Curaçao', + capital: 'Willemstad', + languages: ['Dutch', '(Eastern) Punjabi', 'English'], + population: 154843, + flag: 'https://restcountries.eu/data/cuw.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Cyprus', + capital: 'Nicosia', + languages: ['Greek (modern)', 'Turkish', 'Armenian'], + population: 847000, + flag: 'https://restcountries.eu/data/cyp.svg', + currency: 'Euro' + }, + { + name: 'Czech Republic', + capital: 'Prague', + languages: ['Czech', 'Slovak'], + population: 10558524, + flag: 'https://restcountries.eu/data/cze.svg', + currency: 'Czech koruna' + }, + { + name: 'Denmark', + capital: 'Copenhagen', + languages: ['Danish'], + population: 5717014, + flag: 'https://restcountries.eu/data/dnk.svg', + currency: 'Danish krone' + }, + { + name: 'Djibouti', + capital: 'Djibouti', + languages: ['French', 'Arabic'], + population: 900000, + flag: 'https://restcountries.eu/data/dji.svg', + currency: 'Djiboutian franc' + }, + { + name: 'Dominica', + capital: 'Roseau', + languages: ['English'], + population: 71293, + flag: 'https://restcountries.eu/data/dma.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Dominican Republic', + capital: 'Santo Domingo', + languages: ['Spanish'], + population: 10075045, + flag: 'https://restcountries.eu/data/dom.svg', + currency: 'Dominican peso' + }, + { + name: 'Ecuador', + capital: 'Quito', + languages: ['Spanish'], + population: 16545799, + flag: 'https://restcountries.eu/data/ecu.svg', + currency: 'United States dollar' + }, + { + name: 'Egypt', + capital: 'Cairo', + languages: ['Arabic'], + population: 91290000, + flag: 'https://restcountries.eu/data/egy.svg', + currency: 'Egyptian pound' + }, + { + name: 'El Salvador', + capital: 'San Salvador', + languages: ['Spanish'], + population: 6520675, + flag: 'https://restcountries.eu/data/slv.svg', + currency: 'United States dollar' + }, + { + name: 'Equatorial Guinea', + capital: 'Malabo', + languages: ['Spanish', 'French'], + population: 1222442, + flag: 'https://restcountries.eu/data/gnq.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Eritrea', + capital: 'Asmara', + languages: ['Tigrinya', 'Arabic', 'English'], + population: 5352000, + flag: 'https://restcountries.eu/data/eri.svg', + currency: 'Eritrean nakfa' + }, + { + name: 'Estonia', + capital: 'Tallinn', + languages: ['Estonian'], + population: 1315944, + flag: 'https://restcountries.eu/data/est.svg', + currency: 'Euro' + }, + { + name: 'Ethiopia', + capital: 'Addis Ababa', + languages: ['Amharic'], + population: 92206005, + flag: 'https://restcountries.eu/data/eth.svg', + currency: 'Ethiopian birr' + }, + { + name: 'Falkland Islands (Malvinas)', + capital: 'Stanley', + languages: ['English'], + population: 2563, + flag: 'https://restcountries.eu/data/flk.svg', + currency: 'Falkland Islands pound' + }, + { + name: 'Faroe Islands', + capital: 'Tórshavn', + languages: ['Faroese'], + population: 49376, + flag: 'https://restcountries.eu/data/fro.svg', + currency: 'Danish krone' + }, + { + name: 'Fiji', + capital: 'Suva', + languages: ['English', 'Fijian', 'Hindi', 'Urdu'], + population: 867000, + flag: 'https://restcountries.eu/data/fji.svg', + currency: 'Fijian dollar' + }, + { + name: 'Finland', + capital: 'Helsinki', + languages: ['Finnish', 'Swedish'], + population: 5491817, + flag: 'https://restcountries.eu/data/fin.svg', + currency: 'Euro' + }, + { + name: 'France', + capital: 'Paris', + languages: ['French'], + population: 66710000, + flag: 'https://restcountries.eu/data/fra.svg', + currency: 'Euro' + }, + { + name: 'French Guiana', + capital: 'Cayenne', + languages: ['French'], + population: 254541, + flag: 'https://restcountries.eu/data/guf.svg', + currency: 'Euro' + }, + { + name: 'French Polynesia', + capital: 'Papeetē', + languages: ['French'], + population: 271800, + flag: 'https://restcountries.eu/data/pyf.svg', + currency: 'CFP franc' + }, + { + name: 'French Southern Territories', + capital: 'Port-aux-Français', + languages: ['French'], + population: 140, + flag: 'https://restcountries.eu/data/atf.svg', + currency: 'Euro' + }, + { + name: 'Gabon', + capital: 'Libreville', + languages: ['French'], + population: 1802278, + flag: 'https://restcountries.eu/data/gab.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Gambia', + capital: 'Banjul', + languages: ['English'], + population: 1882450, + flag: 'https://restcountries.eu/data/gmb.svg', + currency: 'Gambian dalasi' + }, + { + name: 'Georgia', + capital: 'Tbilisi', + languages: ['Georgian'], + population: 3720400, + flag: 'https://restcountries.eu/data/geo.svg', + currency: 'Georgian Lari' + }, + { + name: 'Germany', + capital: 'Berlin', + languages: ['German'], + population: 81770900, + flag: 'https://restcountries.eu/data/deu.svg', + currency: 'Euro' + }, + { + name: 'Ghana', + capital: 'Accra', + languages: ['English'], + population: 27670174, + flag: 'https://restcountries.eu/data/gha.svg', + currency: 'Ghanaian cedi' + }, + { + name: 'Gibraltar', + capital: 'Gibraltar', + languages: ['English'], + population: 33140, + flag: 'https://restcountries.eu/data/gib.svg', + currency: 'Gibraltar pound' + }, + { + name: 'Greece', + capital: 'Athens', + languages: ['Greek (modern)'], + population: 10858018, + flag: 'https://restcountries.eu/data/grc.svg', + currency: 'Euro' + }, + { + name: 'Greenland', + capital: 'Nuuk', + languages: ['Kalaallisut'], + population: 55847, + flag: 'https://restcountries.eu/data/grl.svg', + currency: 'Danish krone' + }, + { + name: 'Grenada', + capital: "St. George's", + languages: ['English'], + population: 103328, + flag: 'https://restcountries.eu/data/grd.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Guadeloupe', + capital: 'Basse-Terre', + languages: ['French'], + population: 400132, + flag: 'https://restcountries.eu/data/glp.svg', + currency: 'Euro' + }, + { + name: 'Guam', + capital: 'Hagåtña', + languages: ['English', 'Chamorro', 'Spanish'], + population: 184200, + flag: 'https://restcountries.eu/data/gum.svg', + currency: 'United States dollar' + }, + { + name: 'Guatemala', + capital: 'Guatemala City', + languages: ['Spanish'], + population: 16176133, + flag: 'https://restcountries.eu/data/gtm.svg', + currency: 'Guatemalan quetzal' + }, + { + name: 'Guernsey', + capital: 'St. Peter Port', + languages: ['English', 'French'], + population: 62999, + flag: 'https://restcountries.eu/data/ggy.svg', + currency: 'British pound' + }, + { + name: 'Guinea', + capital: 'Conakry', + languages: ['French', 'Fula'], + population: 12947000, + flag: 'https://restcountries.eu/data/gin.svg', + currency: 'Guinean franc' + }, + { + name: 'Guinea-Bissau', + capital: 'Bissau', + languages: ['Portuguese'], + population: 1547777, + flag: 'https://restcountries.eu/data/gnb.svg', + currency: 'West African CFA franc' + }, + { + name: 'Guyana', + capital: 'Georgetown', + languages: ['English'], + population: 746900, + flag: 'https://restcountries.eu/data/guy.svg', + currency: 'Guyanese dollar' + }, + { + name: 'Haiti', + capital: 'Port-au-Prince', + languages: ['French', 'Haitian'], + population: 11078033, + flag: 'https://restcountries.eu/data/hti.svg', + currency: 'Haitian gourde' + }, + { + name: 'Heard Island and McDonald Islands', + capital: '', + languages: ['English'], + population: 0, + flag: 'https://restcountries.eu/data/hmd.svg', + currency: 'Australian dollar' + }, + { + name: 'Holy See', + capital: 'Rome', + languages: ['Latin', 'Italian', 'French', 'German'], + population: 451, + flag: 'https://restcountries.eu/data/vat.svg', + currency: 'Euro' + }, + { + name: 'Honduras', + capital: 'Tegucigalpa', + languages: ['Spanish'], + population: 8576532, + flag: 'https://restcountries.eu/data/hnd.svg', + currency: 'Honduran lempira' + }, + { + name: 'Hong Kong', + capital: 'City of Victoria', + languages: ['English', 'Chinese'], + population: 7324300, + flag: 'https://restcountries.eu/data/hkg.svg', + currency: 'Hong Kong dollar' + }, + { + name: 'Hungary', + capital: 'Budapest', + languages: ['Hungarian'], + population: 9823000, + flag: 'https://restcountries.eu/data/hun.svg', + currency: 'Hungarian forint' + }, + { + name: 'Iceland', + capital: 'Reykjavík', + languages: ['Icelandic'], + population: 334300, + flag: 'https://restcountries.eu/data/isl.svg', + currency: 'Icelandic króna' + }, + { + name: 'India', + capital: 'New Delhi', + languages: ['Hindi', 'English'], + population: 1295210000, + flag: 'https://restcountries.eu/data/ind.svg', + currency: 'Indian rupee' + }, + { + name: 'Indonesia', + capital: 'Jakarta', + languages: ['Indonesian'], + population: 258705000, + flag: 'https://restcountries.eu/data/idn.svg', + currency: 'Indonesian rupiah' + }, + { + name: "Côte d'Ivoire", + capital: 'Yamoussoukro', + languages: ['French'], + population: 22671331, + flag: 'https://restcountries.eu/data/civ.svg', + currency: 'West African CFA franc' + }, + { + name: 'Iran (Islamic Republic of)', + capital: 'Tehran', + languages: ['Persian (Farsi)'], + population: 79369900, + flag: 'https://restcountries.eu/data/irn.svg', + currency: 'Iranian rial' + }, + { + name: 'Iraq', + capital: 'Baghdad', + languages: ['Arabic', 'Kurdish'], + population: 37883543, + flag: 'https://restcountries.eu/data/irq.svg', + currency: 'Iraqi dinar' + }, + { + name: 'Ireland', + capital: 'Dublin', + languages: ['Irish', 'English'], + population: 6378000, + flag: 'https://restcountries.eu/data/irl.svg', + currency: 'Euro' + }, + { + name: 'Isle of Man', + capital: 'Douglas', + languages: ['English', 'Manx'], + population: 84497, + flag: 'https://restcountries.eu/data/imn.svg', + currency: 'British pound' + }, + { + name: 'Israel', + capital: 'Jerusalem', + languages: ['Hebrew (modern)', 'Arabic'], + population: 8527400, + flag: 'https://restcountries.eu/data/isr.svg', + currency: 'Israeli new shekel' + }, + { + name: 'Italy', + capital: 'Rome', + languages: ['Italian'], + population: 60665551, + flag: 'https://restcountries.eu/data/ita.svg', + currency: 'Euro' + }, + { + name: 'Jamaica', + capital: 'Kingston', + languages: ['English'], + population: 2723246, + flag: 'https://restcountries.eu/data/jam.svg', + currency: 'Jamaican dollar' + }, + { + name: 'Japan', + capital: 'Tokyo', + languages: ['Japanese'], + population: 126960000, + flag: 'https://restcountries.eu/data/jpn.svg', + currency: 'Japanese yen' + }, + { + name: 'Jersey', + capital: 'Saint Helier', + languages: ['English', 'French'], + population: 100800, + flag: 'https://restcountries.eu/data/jey.svg', + currency: 'British pound' + }, + { + name: 'Jordan', + capital: 'Amman', + languages: ['Arabic'], + population: 9531712, + flag: 'https://restcountries.eu/data/jor.svg', + currency: 'Jordanian dinar' + }, + { + name: 'Kazakhstan', + capital: 'Astana', + languages: ['Kazakh', 'Russian'], + population: 17753200, + flag: 'https://restcountries.eu/data/kaz.svg', + currency: 'Kazakhstani tenge' + }, + { + name: 'Kenya', + capital: 'Nairobi', + languages: ['English', 'Swahili'], + population: 47251000, + flag: 'https://restcountries.eu/data/ken.svg', + currency: 'Kenyan shilling' + }, + { + name: 'Kiribati', + capital: 'South Tarawa', + languages: ['English'], + population: 113400, + flag: 'https://restcountries.eu/data/kir.svg', + currency: 'Australian dollar' + }, + { + name: 'Kuwait', + capital: 'Kuwait City', + languages: ['Arabic'], + population: 4183658, + flag: 'https://restcountries.eu/data/kwt.svg', + currency: 'Kuwaiti dinar' + }, + { + name: 'Kyrgyzstan', + capital: 'Bishkek', + languages: ['Kyrgyz', 'Russian'], + population: 6047800, + flag: 'https://restcountries.eu/data/kgz.svg', + currency: 'Kyrgyzstani som' + }, + { + name: "Lao People's Democratic Republic", + capital: 'Vientiane', + languages: ['Lao'], + population: 6492400, + flag: 'https://restcountries.eu/data/lao.svg', + currency: 'Lao kip' + }, + { + name: 'Latvia', + capital: 'Riga', + languages: ['Latvian'], + population: 1961600, + flag: 'https://restcountries.eu/data/lva.svg', + currency: 'Euro' + }, + { + name: 'Lebanon', + capital: 'Beirut', + languages: ['Arabic', 'French'], + population: 5988000, + flag: 'https://restcountries.eu/data/lbn.svg', + currency: 'Lebanese pound' + }, + { + name: 'Lesotho', + capital: 'Maseru', + languages: ['English', 'Southern Sotho'], + population: 1894194, + flag: 'https://restcountries.eu/data/lso.svg', + currency: 'Lesotho loti' + }, + { + name: 'Liberia', + capital: 'Monrovia', + languages: ['English'], + population: 4615000, + flag: 'https://restcountries.eu/data/lbr.svg', + currency: 'Liberian dollar' + }, + { + name: 'Libya', + capital: 'Tripoli', + languages: ['Arabic'], + population: 6385000, + flag: 'https://restcountries.eu/data/lby.svg', + currency: 'Libyan dinar' + }, + { + name: 'Liechtenstein', + capital: 'Vaduz', + languages: ['German'], + population: 37623, + flag: 'https://restcountries.eu/data/lie.svg', + currency: 'Swiss franc' + }, + { + name: 'Lithuania', + capital: 'Vilnius', + languages: ['Lithuanian'], + population: 2872294, + flag: 'https://restcountries.eu/data/ltu.svg', + currency: 'Euro' + }, + { + name: 'Luxembourg', + capital: 'Luxembourg', + languages: ['French', 'German', 'Luxembourgish'], + population: 576200, + flag: 'https://restcountries.eu/data/lux.svg', + currency: 'Euro' + }, + { + name: 'Macao', + capital: '', + languages: ['Chinese', 'Portuguese'], + population: 649100, + flag: 'https://restcountries.eu/data/mac.svg', + currency: 'Macanese pataca' + }, + { + name: 'Macedonia (the former Yugoslav Republic of)', + capital: 'Skopje', + languages: ['Macedonian'], + population: 2058539, + flag: 'https://restcountries.eu/data/mkd.svg', + currency: 'Macedonian denar' + }, + { + name: 'Madagascar', + capital: 'Antananarivo', + languages: ['French', 'Malagasy'], + population: 22434363, + flag: 'https://restcountries.eu/data/mdg.svg', + currency: 'Malagasy ariary' + }, + { + name: 'Malawi', + capital: 'Lilongwe', + languages: ['English', 'Chichewa'], + population: 16832910, + flag: 'https://restcountries.eu/data/mwi.svg', + currency: 'Malawian kwacha' + }, + { + name: 'Malaysia', + capital: 'Kuala Lumpur', + languages: ['Malaysian'], + population: 31405416, + flag: 'https://restcountries.eu/data/mys.svg', + currency: 'Malaysian ringgit' + }, + { + name: 'Maldives', + capital: 'Malé', + languages: ['Divehi'], + population: 344023, + flag: 'https://restcountries.eu/data/mdv.svg', + currency: 'Maldivian rufiyaa' + }, + { + name: 'Mali', + capital: 'Bamako', + languages: ['French'], + population: 18135000, + flag: 'https://restcountries.eu/data/mli.svg', + currency: 'West African CFA franc' + }, + { + name: 'Malta', + capital: 'Valletta', + languages: ['Maltese', 'English'], + population: 425384, + flag: 'https://restcountries.eu/data/mlt.svg', + currency: 'Euro' + }, + { + name: 'Marshall Islands', + capital: 'Majuro', + languages: ['English', 'Marshallese'], + population: 54880, + flag: 'https://restcountries.eu/data/mhl.svg', + currency: 'United States dollar' + }, + { + name: 'Martinique', + capital: 'Fort-de-France', + languages: ['French'], + population: 378243, + flag: 'https://restcountries.eu/data/mtq.svg', + currency: 'Euro' + }, + { + name: 'Mauritania', + capital: 'Nouakchott', + languages: ['Arabic'], + population: 3718678, + flag: 'https://restcountries.eu/data/mrt.svg', + currency: 'Mauritanian ouguiya' + }, + { + name: 'Mauritius', + capital: 'Port Louis', + languages: ['English'], + population: 1262879, + flag: 'https://restcountries.eu/data/mus.svg', + currency: 'Mauritian rupee' + }, + { + name: 'Mayotte', + capital: 'Mamoudzou', + languages: ['French'], + population: 226915, + flag: 'https://restcountries.eu/data/myt.svg', + currency: 'Euro' + }, + { + name: 'Mexico', + capital: 'Mexico City', + languages: ['Spanish'], + population: 122273473, + flag: 'https://restcountries.eu/data/mex.svg', + currency: 'Mexican peso' + }, + { + name: 'Micronesia (Federated States of)', + capital: 'Palikir', + languages: ['English'], + population: 102800, + flag: 'https://restcountries.eu/data/fsm.svg', + currency: '[D]' + }, + { + name: 'Moldova (Republic of)', + capital: 'Chișinău', + languages: ['Romanian'], + population: 3553100, + flag: 'https://restcountries.eu/data/mda.svg', + currency: 'Moldovan leu' + }, + { + name: 'Monaco', + capital: 'Monaco', + languages: ['French'], + population: 38400, + flag: 'https://restcountries.eu/data/mco.svg', + currency: 'Euro' + }, + { + name: 'Mongolia', + capital: 'Ulan Bator', + languages: ['Mongolian'], + population: 3093100, + flag: 'https://restcountries.eu/data/mng.svg', + currency: 'Mongolian tögrög' + }, + { + name: 'Montenegro', + capital: 'Podgorica', + languages: ['Serbian', 'Bosnian', 'Albanian', 'Croatian'], + population: 621810, + flag: 'https://restcountries.eu/data/mne.svg', + currency: 'Euro' + }, + { + name: 'Montserrat', + capital: 'Plymouth', + languages: ['English'], + population: 4922, + flag: 'https://restcountries.eu/data/msr.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Morocco', + capital: 'Rabat', + languages: ['Arabic'], + population: 33337529, + flag: 'https://restcountries.eu/data/mar.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Mozambique', + capital: 'Maputo', + languages: ['Portuguese'], + population: 26423700, + flag: 'https://restcountries.eu/data/moz.svg', + currency: 'Mozambican metical' + }, + { + name: 'Myanmar', + capital: 'Naypyidaw', + languages: ['Burmese'], + population: 51419420, + flag: 'https://restcountries.eu/data/mmr.svg', + currency: 'Burmese kyat' + }, + { + name: 'Namibia', + capital: 'Windhoek', + languages: ['English', 'Afrikaans'], + population: 2324388, + flag: 'https://restcountries.eu/data/nam.svg', + currency: 'Namibian dollar' + }, + { + name: 'Nauru', + capital: 'Yaren', + languages: ['English', 'Nauruan'], + population: 10084, + flag: 'https://restcountries.eu/data/nru.svg', + currency: 'Australian dollar' + }, + { + name: 'Nepal', + capital: 'Kathmandu', + languages: ['Nepali'], + population: 28431500, + flag: 'https://restcountries.eu/data/npl.svg', + currency: 'Nepalese rupee' + }, + { + name: 'Netherlands', + capital: 'Amsterdam', + languages: ['Dutch'], + population: 17019800, + flag: 'https://restcountries.eu/data/nld.svg', + currency: 'Euro' + }, + { + name: 'New Caledonia', + capital: 'Nouméa', + languages: ['French'], + population: 268767, + flag: 'https://restcountries.eu/data/ncl.svg', + currency: 'CFP franc' + }, + { + name: 'New Zealand', + capital: 'Wellington', + languages: ['English', 'Māori'], + population: 4697854, + flag: 'https://restcountries.eu/data/nzl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Nicaragua', + capital: 'Managua', + languages: ['Spanish'], + population: 6262703, + flag: 'https://restcountries.eu/data/nic.svg', + currency: 'Nicaraguan córdoba' + }, + { + name: 'Niger', + capital: 'Niamey', + languages: ['French'], + population: 20715000, + flag: 'https://restcountries.eu/data/ner.svg', + currency: 'West African CFA franc' + }, + { + name: 'Nigeria', + capital: 'Abuja', + languages: ['English'], + population: 186988000, + flag: 'https://restcountries.eu/data/nga.svg', + currency: 'Nigerian naira' + }, + { + name: 'Niue', + capital: 'Alofi', + languages: ['English'], + population: 1470, + flag: 'https://restcountries.eu/data/niu.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Norfolk Island', + capital: 'Kingston', + languages: ['English'], + population: 2302, + flag: 'https://restcountries.eu/data/nfk.svg', + currency: 'Australian dollar' + }, + { + name: "Korea (Democratic People's Republic of)", + capital: 'Pyongyang', + languages: ['Korean'], + population: 25281000, + flag: 'https://restcountries.eu/data/prk.svg', + currency: 'North Korean won' + }, + { + name: 'Northern Mariana Islands', + capital: 'Saipan', + languages: ['English', 'Chamorro'], + population: 56940, + flag: 'https://restcountries.eu/data/mnp.svg', + currency: 'United States dollar' + }, + { + name: 'Norway', + capital: 'Oslo', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 5223256, + flag: 'https://restcountries.eu/data/nor.svg', + currency: 'Norwegian krone' + }, + { + name: 'Oman', + capital: 'Muscat', + languages: ['Arabic'], + population: 4420133, + flag: 'https://restcountries.eu/data/omn.svg', + currency: 'Omani rial' + }, + { + name: 'Pakistan', + capital: 'Islamabad', + languages: ['English', 'Urdu'], + population: 194125062, + flag: 'https://restcountries.eu/data/pak.svg', + currency: 'Pakistani rupee' + }, + { + name: 'Palau', + capital: 'Ngerulmud', + languages: ['English'], + population: 17950, + flag: 'https://restcountries.eu/data/plw.svg', + currency: '[E]' + }, + { + name: 'Palestine, State of', + capital: 'Ramallah', + languages: ['Arabic'], + population: 4682467, + flag: 'https://restcountries.eu/data/pse.svg', + currency: 'Israeli new sheqel' + }, + { + name: 'Panama', + capital: 'Panama City', + languages: ['Spanish'], + population: 3814672, + flag: 'https://restcountries.eu/data/pan.svg', + currency: 'Panamanian balboa' + }, + { + name: 'Papua New Guinea', + capital: 'Port Moresby', + languages: ['English'], + population: 8083700, + flag: 'https://restcountries.eu/data/png.svg', + currency: 'Papua New Guinean kina' + }, + { + name: 'Paraguay', + capital: 'Asunción', + languages: ['Spanish', 'Guaraní'], + population: 6854536, + flag: 'https://restcountries.eu/data/pry.svg', + currency: 'Paraguayan guaraní' + }, + { + name: 'Peru', + capital: 'Lima', + languages: ['Spanish'], + population: 31488700, + flag: 'https://restcountries.eu/data/per.svg', + currency: 'Peruvian sol' + }, + { + name: 'Philippines', + capital: 'Manila', + languages: ['English'], + population: 103279800, + flag: 'https://restcountries.eu/data/phl.svg', + currency: 'Philippine peso' + }, + { + name: 'Pitcairn', + capital: 'Adamstown', + languages: ['English'], + population: 56, + flag: 'https://restcountries.eu/data/pcn.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Poland', + capital: 'Warsaw', + languages: ['Polish'], + population: 38437239, + flag: 'https://restcountries.eu/data/pol.svg', + currency: 'Polish złoty' + }, + { + name: 'Portugal', + capital: 'Lisbon', + languages: ['Portuguese'], + population: 10374822, + flag: 'https://restcountries.eu/data/prt.svg', + currency: 'Euro' + }, + { + name: 'Puerto Rico', + capital: 'San Juan', + languages: ['Spanish', 'English'], + population: 3474182, + flag: 'https://restcountries.eu/data/pri.svg', + currency: 'United States dollar' + }, + { + name: 'Qatar', + capital: 'Doha', + languages: ['Arabic'], + population: 2587564, + flag: 'https://restcountries.eu/data/qat.svg', + currency: 'Qatari riyal' + }, + { + name: 'Republic of Kosovo', + capital: 'Pristina', + languages: ['Albanian', 'Serbian'], + population: 1733842, + flag: 'https://restcountries.eu/data/kos.svg', + currency: 'Euro' + }, + { + name: 'Réunion', + capital: 'Saint-Denis', + languages: ['French'], + population: 840974, + flag: 'https://restcountries.eu/data/reu.svg', + currency: 'Euro' + }, + { + name: 'Romania', + capital: 'Bucharest', + languages: ['Romanian'], + population: 19861408, + flag: 'https://restcountries.eu/data/rou.svg', + currency: 'Romanian leu' + }, + { + name: 'Russian Federation', + capital: 'Moscow', + languages: ['Russian'], + population: 146599183, + flag: 'https://restcountries.eu/data/rus.svg', + currency: 'Russian ruble' + }, + { + name: 'Rwanda', + capital: 'Kigali', + languages: ['Kinyarwanda', 'English', 'French'], + population: 11553188, + flag: 'https://restcountries.eu/data/rwa.svg', + currency: 'Rwandan franc' + }, + { + name: 'Saint Barthélemy', + capital: 'Gustavia', + languages: ['French'], + population: 9417, + flag: 'https://restcountries.eu/data/blm.svg', + currency: 'Euro' + }, + { + name: 'Saint Helena, Ascension and Tristan da Cunha', + capital: 'Jamestown', + languages: ['English'], + population: 4255, + flag: 'https://restcountries.eu/data/shn.svg', + currency: 'Saint Helena pound' + }, + { + name: 'Saint Kitts and Nevis', + capital: 'Basseterre', + languages: ['English'], + population: 46204, + flag: 'https://restcountries.eu/data/kna.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Lucia', + capital: 'Castries', + languages: ['English'], + population: 186000, + flag: 'https://restcountries.eu/data/lca.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Martin (French part)', + capital: 'Marigot', + languages: ['English', 'French', 'Dutch'], + population: 36979, + flag: 'https://restcountries.eu/data/maf.svg', + currency: 'Euro' + }, + { + name: 'Saint Pierre and Miquelon', + capital: 'Saint-Pierre', + languages: ['French'], + population: 6069, + flag: 'https://restcountries.eu/data/spm.svg', + currency: 'Euro' + }, + { + name: 'Saint Vincent and the Grenadines', + capital: 'Kingstown', + languages: ['English'], + population: 109991, + flag: 'https://restcountries.eu/data/vct.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Samoa', + capital: 'Apia', + languages: ['Samoan', 'English'], + population: 194899, + flag: 'https://restcountries.eu/data/wsm.svg', + currency: 'Samoan tālā' + }, + { + name: 'San Marino', + capital: 'City of San Marino', + languages: ['Italian'], + population: 33005, + flag: 'https://restcountries.eu/data/smr.svg', + currency: 'Euro' + }, + { + name: 'Sao Tome and Principe', + capital: 'São Tomé', + languages: ['Portuguese'], + population: 187356, + flag: 'https://restcountries.eu/data/stp.svg', + currency: 'São Tomé and Príncipe dobra' + }, + { + name: 'Saudi Arabia', + capital: 'Riyadh', + languages: ['Arabic'], + population: 32248200, + flag: 'https://restcountries.eu/data/sau.svg', + currency: 'Saudi riyal' + }, + { + name: 'Senegal', + capital: 'Dakar', + languages: ['French'], + population: 14799859, + flag: 'https://restcountries.eu/data/sen.svg', + currency: 'West African CFA franc' + }, + { + name: 'Serbia', + capital: 'Belgrade', + languages: ['Serbian'], + population: 7076372, + flag: 'https://restcountries.eu/data/srb.svg', + currency: 'Serbian dinar' + }, + { + name: 'Seychelles', + capital: 'Victoria', + languages: ['French', 'English'], + population: 91400, + flag: 'https://restcountries.eu/data/syc.svg', + currency: 'Seychellois rupee' + }, + { + name: 'Sierra Leone', + capital: 'Freetown', + languages: ['English'], + population: 7075641, + flag: 'https://restcountries.eu/data/sle.svg', + currency: 'Sierra Leonean leone' + }, + { + name: 'Singapore', + capital: 'Singapore', + languages: ['English', 'Malay', 'Tamil', 'Chinese'], + population: 5535000, + flag: 'https://restcountries.eu/data/sgp.svg', + currency: 'Brunei dollar' + }, + { + name: 'Sint Maarten (Dutch part)', + capital: 'Philipsburg', + languages: ['Dutch', 'English'], + population: 38247, + flag: 'https://restcountries.eu/data/sxm.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Slovakia', + capital: 'Bratislava', + languages: ['Slovak'], + population: 5426252, + flag: 'https://restcountries.eu/data/svk.svg', + currency: 'Euro' + }, + { + name: 'Slovenia', + capital: 'Ljubljana', + languages: ['Slovene'], + population: 2064188, + flag: 'https://restcountries.eu/data/svn.svg', + currency: 'Euro' + }, + { + name: 'Solomon Islands', + capital: 'Honiara', + languages: ['English'], + population: 642000, + flag: 'https://restcountries.eu/data/slb.svg', + currency: 'Solomon Islands dollar' + }, + { + name: 'Somalia', + capital: 'Mogadishu', + languages: ['Somali', 'Arabic'], + population: 11079000, + flag: 'https://restcountries.eu/data/som.svg', + currency: 'Somali shilling' + }, + { + name: 'South Africa', + capital: 'Pretoria', + languages: [ + 'Afrikaans', + 'English', + 'Southern Ndebele', + 'Southern Sotho', + 'Swati', + 'Tswana', + 'Tsonga', + 'Venda', + 'Xhosa', + 'Zulu' + ], + population: 55653654, + flag: 'https://restcountries.eu/data/zaf.svg', + currency: 'South African rand' + }, + { + name: 'South Georgia and the South Sandwich Islands', + capital: 'King Edward Point', + languages: ['English'], + population: 30, + flag: 'https://restcountries.eu/data/sgs.svg', + currency: 'British pound' + }, + { + name: 'Korea (Republic of)', + capital: 'Seoul', + languages: ['Korean'], + population: 50801405, + flag: 'https://restcountries.eu/data/kor.svg', + currency: 'South Korean won' + }, + { + name: 'South Sudan', + capital: 'Juba', + languages: ['English'], + population: 12131000, + flag: 'https://restcountries.eu/data/ssd.svg', + currency: 'South Sudanese pound' + }, + { + name: 'Spain', + capital: 'Madrid', + languages: ['Spanish'], + population: 46438422, + flag: 'https://restcountries.eu/data/esp.svg', + currency: 'Euro' + }, + { + name: 'Sri Lanka', + capital: 'Colombo', + languages: ['Sinhalese', 'Tamil'], + population: 20966000, + flag: 'https://restcountries.eu/data/lka.svg', + currency: 'Sri Lankan rupee' + }, + { + name: 'Sudan', + capital: 'Khartoum', + languages: ['Arabic', 'English'], + population: 39598700, + flag: 'https://restcountries.eu/data/sdn.svg', + currency: 'Sudanese pound' + }, + { + name: 'Suriname', + capital: 'Paramaribo', + languages: ['Dutch'], + population: 541638, + flag: 'https://restcountries.eu/data/sur.svg', + currency: 'Surinamese dollar' + }, + { + name: 'Svalbard and Jan Mayen', + capital: 'Longyearbyen', + languages: ['Norwegian'], + population: 2562, + flag: 'https://restcountries.eu/data/sjm.svg', + currency: 'Norwegian krone' + }, + { + name: 'Swaziland', + capital: 'Lobamba', + languages: ['English', 'Swati'], + population: 1132657, + flag: 'https://restcountries.eu/data/swz.svg', + currency: 'Swazi lilangeni' + }, + { + name: 'Sweden', + capital: 'Stockholm', + languages: ['Swedish'], + population: 9894888, + flag: 'https://restcountries.eu/data/swe.svg', + currency: 'Swedish krona' + }, + { + name: 'Switzerland', + capital: 'Bern', + languages: ['German', 'French', 'Italian'], + population: 8341600, + flag: 'https://restcountries.eu/data/che.svg', + currency: 'Swiss franc' + }, + { + name: 'Syrian Arab Republic', + capital: 'Damascus', + languages: ['Arabic'], + population: 18564000, + flag: 'https://restcountries.eu/data/syr.svg', + currency: 'Syrian pound' + }, + { + name: 'Taiwan', + capital: 'Taipei', + languages: ['Chinese'], + population: 23503349, + flag: 'https://restcountries.eu/data/twn.svg', + currency: 'New Taiwan dollar' + }, + { + name: 'Tajikistan', + capital: 'Dushanbe', + languages: ['Tajik', 'Russian'], + population: 8593600, + flag: 'https://restcountries.eu/data/tjk.svg', + currency: 'Tajikistani somoni' + }, + { + name: 'Tanzania, United Republic of', + capital: 'Dodoma', + languages: ['Swahili', 'English'], + population: 55155000, + flag: 'https://restcountries.eu/data/tza.svg', + currency: 'Tanzanian shilling' + }, + { + name: 'Thailand', + capital: 'Bangkok', + languages: ['Thai'], + population: 65327652, + flag: 'https://restcountries.eu/data/tha.svg', + currency: 'Thai baht' + }, + { + name: 'Timor-Leste', + capital: 'Dili', + languages: ['Portuguese'], + population: 1167242, + flag: 'https://restcountries.eu/data/tls.svg', + currency: 'United States dollar' + }, + { + name: 'Togo', + capital: 'Lomé', + languages: ['French'], + population: 7143000, + flag: 'https://restcountries.eu/data/tgo.svg', + currency: 'West African CFA franc' + }, + { + name: 'Tokelau', + capital: 'Fakaofo', + languages: ['English'], + population: 1411, + flag: 'https://restcountries.eu/data/tkl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Tonga', + capital: "Nuku'alofa", + languages: ['English', 'Tonga (Tonga Islands)'], + population: 103252, + flag: 'https://restcountries.eu/data/ton.svg', + currency: 'Tongan paʻanga' + }, + { + name: 'Trinidad and Tobago', + capital: 'Port of Spain', + languages: ['English'], + population: 1349667, + flag: 'https://restcountries.eu/data/tto.svg', + currency: 'Trinidad and Tobago dollar' + }, + { + name: 'Tunisia', + capital: 'Tunis', + languages: ['Arabic'], + population: 11154400, + flag: 'https://restcountries.eu/data/tun.svg', + currency: 'Tunisian dinar' + }, + { + name: 'Turkey', + capital: 'Ankara', + languages: ['Turkish'], + population: 78741053, + flag: 'https://restcountries.eu/data/tur.svg', + currency: 'Turkish lira' + }, + { + name: 'Turkmenistan', + capital: 'Ashgabat', + languages: ['Turkmen', 'Russian'], + population: 4751120, + flag: 'https://restcountries.eu/data/tkm.svg', + currency: 'Turkmenistan manat' + }, + { + name: 'Turks and Caicos Islands', + capital: 'Cockburn Town', + languages: ['English'], + population: 31458, + flag: 'https://restcountries.eu/data/tca.svg', + currency: 'United States dollar' + }, + { + name: 'Tuvalu', + capital: 'Funafuti', + languages: ['English'], + population: 10640, + flag: 'https://restcountries.eu/data/tuv.svg', + currency: 'Australian dollar' + }, + { + name: 'Uganda', + capital: 'Kampala', + languages: ['English', 'Swahili'], + population: 33860700, + flag: 'https://restcountries.eu/data/uga.svg', + currency: 'Ugandan shilling' + }, + { + name: 'Ukraine', + capital: 'Kiev', + languages: ['Ukrainian'], + population: 42692393, + flag: 'https://restcountries.eu/data/ukr.svg', + currency: 'Ukrainian hryvnia' + }, + { + name: 'United Arab Emirates', + capital: 'Abu Dhabi', + languages: ['Arabic'], + population: 9856000, + flag: 'https://restcountries.eu/data/are.svg', + currency: 'United Arab Emirates dirham' + }, + { + name: 'United Kingdom of Great Britain and Northern Ireland', + capital: 'London', + languages: ['English'], + population: 65110000, + flag: 'https://restcountries.eu/data/gbr.svg', + currency: 'British pound' + }, + { + name: 'United States of America', + capital: 'Washington, D.C.', + languages: ['English'], + population: 323947000, + flag: 'https://restcountries.eu/data/usa.svg', + currency: 'United States dollar' + }, + { + name: 'Uruguay', + capital: 'Montevideo', + languages: ['Spanish'], + population: 3480222, + flag: 'https://restcountries.eu/data/ury.svg', + currency: 'Uruguayan peso' + }, + { + name: 'Uzbekistan', + capital: 'Tashkent', + languages: ['Uzbek', 'Russian'], + population: 31576400, + flag: 'https://restcountries.eu/data/uzb.svg', + currency: "Uzbekistani so'm" + }, + { + name: 'Vanuatu', + capital: 'Port Vila', + languages: ['Bislama', 'English', 'French'], + population: 277500, + flag: 'https://restcountries.eu/data/vut.svg', + currency: 'Vanuatu vatu' + }, + { + name: 'Venezuela (Bolivarian Republic of)', + capital: 'Caracas', + languages: ['Spanish'], + population: 31028700, + flag: 'https://restcountries.eu/data/ven.svg', + currency: 'Venezuelan bolívar' + }, + { + name: 'Viet Nam', + capital: 'Hanoi', + languages: ['Vietnamese'], + population: 92700000, + flag: 'https://restcountries.eu/data/vnm.svg', + currency: 'Vietnamese đồng' + }, + { + name: 'Wallis and Futuna', + capital: 'Mata-Utu', + languages: ['French'], + population: 11750, + flag: 'https://restcountries.eu/data/wlf.svg', + currency: 'CFP franc' + }, + { + name: 'Western Sahara', + capital: 'El Aaiún', + languages: ['Spanish'], + population: 510713, + flag: 'https://restcountries.eu/data/esh.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Yemen', + capital: "Sana'a", + languages: ['Arabic'], + population: 27478000, + flag: 'https://restcountries.eu/data/yem.svg', + currency: 'Yemeni rial' + }, + { + name: 'Zambia', + capital: 'Lusaka', + languages: ['English'], + population: 15933883, + flag: 'https://restcountries.eu/data/zmb.svg', + currency: 'Zambian kwacha' + }, + { + name: 'Zimbabwe', + capital: 'Harare', + languages: ['English', 'Shona', 'Northern Ndebele'], + population: 14240168, + flag: 'https://restcountries.eu/data/zwe.svg', + currency: 'Botswana pula' + } +] diff --git a/20_Day_Writing_clean_codes/20_day_starter/index.html b/20_Day_Writing_clean_codes/20_day_starter/index.html new file mode 100644 index 0000000..ba00ff9 --- /dev/null +++ b/20_Day_Writing_clean_codes/20_day_starter/index.html @@ -0,0 +1,17 @@ + + + + + 30DaysOfJavaScript:20 Day + + + +

30DaysOfJavaScript:20 Day

+

Writing clean code

+ + + + + + + \ No newline at end of file diff --git a/20_Day_Writing_clean_codes/20_day_starter/scripts/main.js b/20_Day_Writing_clean_codes/20_day_starter/scripts/main.js new file mode 100644 index 0000000..c6045c8 --- /dev/null +++ b/20_Day_Writing_clean_codes/20_day_starter/scripts/main.js @@ -0,0 +1,2 @@ +console.log(countries) +alert('Open the console and check if the countries has been loaded') \ No newline at end of file diff --git a/20_Day_Writing_clean_codes/20_day_writing_clean_codes.md b/20_Day_Writing_clean_codes/20_day_writing_clean_codes.md new file mode 100644 index 0000000..50ed23a --- /dev/null +++ b/20_Day_Writing_clean_codes/20_day_writing_clean_codes.md @@ -0,0 +1,359 @@ +
+

30 Days Of JavaScript: Writing Clean Codes

+ + + + + Twitter Follow + + +Author: +Asabeneh Yetayeh
+ January, 2020 +
+ +
+ +[<< Day 19](../19_Day_Closuers/19_day_closures.md) | [Day 21 >>](../21_Day_DOM/21_day_dom.md) + +![Thirty Days Of JavaScript](../images/banners/day_1_20.png) +- [Day 20](#day-20) + - [Writing clean code](#writing-clean-code) + - [JavaScript Style Guide](#javascript-style-guide) + - [Why we need style guide](#why-we-need-style-guide) + - [Airbnb JavaScript Style Guide](#airbnb-javascript-style-guide) + - [Standard JavaScript Style Guide](#standard-javascript-style-guide) + - [Google JavaScript Style Guide](#google-javascript-style-guide) + - [JavaScript Coding Conventions](#javascript-coding-conventions) + - [Conventions use in 30DaysOfJavaScript](#conventions-use-in-30daysofjavascript) + - [Variables](#variables) + - [Arrays](#arrays) + - [Functions](#functions) + - [Loops](#loops) + - [Objects](#objects) + - [Conditional](#conditional) + - [Classes](#classes) + +# Day 20 + +## Writing clean code + +### JavaScript Style Guide + +A JavaScript style guide is a set of standards that tells how JavaScript code should be written and organized. In this section, we will talk about JavaScript guides and how to write a clean code. + +JavaScript is a programming language and like human language it has syntax. The syntax of JavaScript has to be written following a certain style guideline for sake of convince and simplicity. + +### Why we need style guide + +You have been coding alone for so long but now it seems to work in a team. It does not matter in anyway you write you code as long as it running, however when you work in team of 10 or 20 or more developer on one project and on the same code base, the code will be messy and hard to manage if there is no any guidelines to follow. + +You can develop your own guidelines and conventions or you can also adapt well developed guidelines. Let us the most common know guidelines. +Most common JavaScript Style Guides + +- Airbnb JavaScript Style Guide +- JavaScript Standard Style Guide +- Google JavaScript Style Guide + +#### Airbnb JavaScript Style Guide + +Airbnb has one of the most popular JavaScript style guides on the internet. It covers nearly every aspect of JavaScript as well and it is adopted by many developer and companies. You may checkout the [Airbnb style guide](https://github.com/airbnb/javascript). I would also recommend to try it. Their style is very easy to use and simple to understand. + +#### Standard JavaScript Style Guide + +This is guideline is not as popular as Airbnb but it worth to look at it. They removed the semicolon in their [style guide](https://standardjs.com/). + +#### Google JavaScript Style Guide + +I do not say much about Googles guideline and I did not use rather I would suggest you to have a look from this [link](https://google.github.io/styleguide/jsguide.html). + +### JavaScript Coding Conventions + +In this challenge also we used the general JavaScript coding writing conventions and guides. Coding conventions are style guidelines for programming which are developed by an individual, a team or a company. + +Coding conventions helps: + +- to write clean code +- to improve code readability +- to improve code re-useability and maintainability + +Coding conventions includes + +- Naming and declaration rules for variables +- Naming and declaration rules for functions +- Rules for the use of white space, indentation, and comments +- Programming practices and principles + +#### Conventions use in 30DaysOfJavaScript + +In this challenge we follow the regular JavaScript convention but I added also my preference of writing. + +- We used camelCase for variables and functions. +- All variable names start with a letter. +- We chose to use *const* for constants, arrays, objects and functions. In stead of double quote, we chose to use single quote or backtick. Single quote is becoming trendy. +- We also removed semicolons from our code but it is a matter of personal preference. +- Space around arithmetic operators, assignment operators and after comma +- Arrow function instead of function declaration +- Explicit return instead of implicit return if the function is one liner +- No trailing comma in the last value of an object +- We prefer this +=, -=, *= /=, **= instead of the longer version +- When we use console.log() it is good to print with a tag string to identify from where the console is coming + +#### Variables + +```js + +let firstName = 'Asabeneh' +let lastName = 'Yetayeh' +let country = 'Finland' +let city = 'Helsinki' + +const PI = Math.PI +const gravity = 9.81 +``` + +#### Arrays + +We chose to make array names plural + +- names +- numbers +- countries +- languages +- skills +- fruits +- vegetables + +```js +// arrays +const names = ['Asabeneh', 'Mathias', 'Elias', 'Brook'] +const numbers = [0, 3.14, 9.81, 37, 98.6, 100] +const countries = ['Finland', 'Denmark', 'Sweden', 'Norway', 'Iceland'] +const languages = ['Amharic', 'Arabic', 'English', 'French', 'Spanish'] +const skills = ['HTML', 'CSS', 'JavaScript', 'React', 'Python'] +const fruits = ['banana', 'orange', 'mango', 'lemon'] +const vegetables = ['Tomato', 'Potato', 'Cabbage', 'Onion', 'Carrot'] +``` + +#### Functions + +By now you are very familiar function declaration, expression function, arrow function and anonymous function. In this challenge we tend to use arrow function instead of other functions. Arrow function is not a replacement for other functions. In addition, arrow functions and function declarations are not exactly the same. So you should know when to use and when not. I will cover the difference in detail in other sections. We will use explicit return instead of implicit return if the function is one liner + +```js +// function which prints full name of a person +const printFullName = (firstName, lastName) => firstName + ' ' + lastName + +// function which calculate a square of a number +const square = (n) => n * n + +// a function which generate random hexa colors +const hexaColor = () => { + const str = '0123456789abcdef' + let hexa = '#' + let index + for (let i = 0; i < 6; i++) { + index = Math.floor(Math.random() * str.length) + hexa += str[index] + } + return hexa +} + +// a function which shows date and time +const showDateTime = () => { + const now = new Date() + const year = now.getFullYear() + const month = now.getMonth() + 1 + const date = now.getDate() + let hours = now.getHours() + let minutes = now.getMinutes() + if (hours < 10) { + hours = '0' + hours + } + if (minutes < 10) { + minutes = '0' + minutes + } + + const dateMonthYear = date + '.' + month + '.' + year + const time = hours + ':' + minutes + const fullTime = dateMonthYear + ' ' + time + return fullTime +} +``` + +#### Loops + +We coverer many types of loops in this challenges. The regular for loop, while loop, do while loop, for of loop, forEach loop and for in loop. +Lets see how we use them: + +```js +for (let i = 0; i < n; i++){ + console.log() +} + +// declaring an array variable +const names = ['Asabeneh', 'Mathias', 'Elias', 'Brook'] + +// iterating an array using regular for loop +let len = names.length; +for(let i = 0; i < len; i++){ + console.log(names[i].toUpperCas()) +} + + +// iterating an array using for of +for( const name of names) { + console.log(name.toUpperCase()) +} + +// iterating array using forEach +names.forEach((name) => name.toUpperCase()) + + +const person = { + firstName: 'Asabeneh', + lastName: 'Yetayeh', + age: 250, + country: 'Finland', + city: 'Helsinki', + skills: ['HTML','CSS','JavaScript','React','Node','MongoDB','Python','D3.js'], + isMarried: true +} +for(const key in user) { + console.log(key) +} + +``` + +#### Objects + +We declare object literal with *const*. + +```js +// declaring object literal +const person = { + firstName: 'Asabeneh', + lastName: 'Yetayeh', + age: 250, + country: 'Finland', + city: 'Helsinki', + skills: ['HTML','CSS','JavaScript','React','Node','MongoDB','Python','D3.js'], + isMarried: true +} +// iterating through object keys +for(const key in person) { + console.log(key, person[key]) +} + + +``` + +#### Conditional + + We say if, if else, if else if else, switch and ternary operators in previous challenges. + + ```js + // syntax +if (condition) { + // this part of code run for truthy condition +} else { + // this part of code run for false condition +} + ``` + + ```js + // if else +let num = 3 +if (num > 0) { + console.log(`${num} is a positive number`) +} else { + console.log(`${num} is a negative number`) +} +// 3 is a positive number + ``` + + ```js + // if else if else if else + +let a = 0 +if (a > 0) { + console.log(`${a} is a positive number`) +} else if (a < 0) { + console.log(`${a} is a negative number`) +} else if (a == 0) { + console.log(`${a} is zero`) +} else { + console.log(`${a} is not a number`) +} + ``` + + ```js + // Switch More Examples +let dayUserInput = prompt('What day is today ?') +let day = dayUserInput.toLowerCase() + +switch (day) { + case 'monday': + console.log('Today is Monday') + break + case 'tuesday': + console.log('Today is Tuesday') + break + case 'wednesday': + console.log('Today is Wednesday') + break + case 'thursday': + console.log('Today is Thursday') + break + case 'friday': + console.log('Today is Friday') + break + case 'saturday': + console.log('Today is Saturday') + break + case 'sunday': + console.log('Today is Sunday') + break + default: + console.log('It is not a week day.') +} + ``` + + ```js + // ternary + + let isRaining = true +isRaining + ? console.log('You need a rain coat.') + : console.log('No need for a rain coat.') + ``` + +#### Classes + +We declare class with CamelCase which starts with capital letter. + +```js +// syntax +class ClassName { + // code goes here +} +``` + +```js +// defining class +class Person { + constructor(firstName, lastName) { + console.log(this) // Check the output from here + this.firstName = firstName + this.lastName = lastName + } +} + +``` + +Whatever style guide you follow be consistent. Follow some programming paradigms and design patterns. Remember, if you do not write you code in certain order or fashion it will be hard to read your code. So, do a favor for yourself or for someone who is going to read your code by writing readable code. + +🌕 You are tidy. Now, you knew how to write clean code, so anyone who know the English language can understand your code. You are always progressing and you are a head of 20 steps to your way to greatness. + +🎉 CONGRATULATIONS ! 🎉 + +[<< Day 19](../19_Day_Closuers/19_day_closures.md) | [Day 21 >>](../21_Day_DOM/21_day_dom.md) diff --git a/21_Day_DOM/21_day_dom.md b/21_Day_DOM/21_day_dom.md new file mode 100644 index 0000000..5755391 --- /dev/null +++ b/21_Day_DOM/21_day_dom.md @@ -0,0 +1,409 @@ +
+

30 Days Of JavaScript: Document Object Model(DOM)

+ + + + + Twitter Follow + + +Author: +Asabeneh Yetayeh
+ January, 2020 +
+ +
+ +[<< Day 20](../20_Day_Writing_clean_codes/20_day_writing_clean_codes.md) | [Day 22 >>](../22_Day_Manipulating_DOM_object/22_day_manipulating_DOM_object.md) + +![Thirty Days Of JavaScript](../images/banners/day_1_21.png) + +- [Day 21](#day-21) + - [Document Object Model (DOM) - Day 1](#document-object-model-dom---day-1) + - [Getting Element](#getting-element) + - [Getting elements by tag name](#getting-elements-by-tag-name) + - [Getting elements by class name](#getting-elements-by-class-name) + - [Getting an element by id](#getting-an-element-by-id) + - [Getting elements by using querySelector methods](#getting-elements-by-using-queryselector-methods) + - [Adding attribute](#adding-attribute) + - [Adding attribute using setAttribute](#adding-attribute-using-setattribute) + - [Adding attribute without setAttribute](#adding-attribute-without-setattribute) + - [Adding class using classList](#adding-class-using-classlist) + - [Removing class using remove](#removing-class-using-remove) + - [Adding Text to HTML element](#adding-text-to-html-element) + - [Adding Text content using textContent](#adding-text-content-using-textcontent) + - [Adding Text Content using innHTML](#adding-text-content-using-innhtml) + - [Text Content](#text-content) + - [Inner HTML](#inner-html) + - [Adding style](#adding-style) + - [Adding Style Color](#adding-style-color) + - [Adding Style Background Color](#adding-style-background-color) + - [Adding Style Font Size](#adding-style-font-size) + - [Exercises](#exercises) + - [Exercise: Level 1](#exercise-level-1) + - [Exercise: Level 2](#exercise-level-2) + - [Exercise: Level 3](#exercise-level-3) + - [DOM: Mini project 1](#dom-mini-project-1) + +# Day 21 + +## Document Object Model (DOM) - Day 1 + +HTML document is structured as a JavaScript Object. Every HTML element has a different properties which can help to manipulate it. It is possible to get, create, append or remove HTML elements using JavaScript. Check the examples below. Selecting HTML element using JavaScript is similar to selecting using CSS. To select an HTML element, we use tag name, id, class name or other attributes. + +### Getting Element + +We can access already created element or elements using JavaScript. To access or get elements we use different methods. The code below has four _h1_ elements. Let us see the different methods to access the _h1_ elements. + +```html + + + + Document Object Model + + + +

First Title

+

Second Title

+

Third Title

+

+ + + +``` + +#### Getting elements by tag name + +**_getElementsByTagName()_**:takes a take name as a string parameter and this method returns an HTMLCollection object. An HTMLCollection is an array like object of HTML elements. The length property provides the size of the collection. Whenever we use this method we access the individual elements using index or after loop through each individual items. An HTMLCollection does not support all array methods therefore we should use regular for loop instead of forEach. + +```js +// syntax +document.getElementsByTagName('tagname') +``` + +```js +const allTitles = document.getElementsByTagName('h1') + +console.log(allTitles) //HTMCollections +console.log(allTitles.length) // 4 + +for (let i = 0; i < allTitles.length; i++) { + console.log(allTitles[i]) // prints each elements in the HTMLCollection +} +``` + +#### Getting elements by class name + +**_getElementsByClassName()_** method returns an HTMLCollection object. An HTMLCollection is an array like list of HTML elements. The length property provides the size of the collection. It is possible to loop through all the HTMLCollection elements. See the example below + +```js +//syntax +document.getElementsByClassName('classname') +``` + +```js +const allTitles = document.getElementsByClassName('title') + +console.log(allTitles) //HTMCollections +console.log(allTitles.length) // 4 + +for (let i = 0; i < allTitles.length; i++) { + console.log(allTitles[i]) // prints each elements in the HTMLCollection +} +``` + +#### Getting an element by id + +**_getElementsById()_** targets a single HTML element. We pass the id without # as an argument. + +```js +//syntax +document.getElementById('id') +``` + +```js +let firstTitle = document.getElementById('first-title') +console.log(firstTitle) //

First Title

+``` + +#### Getting elements by using querySelector methods + +The _document.querySelector_ method can select an HTML or HTML elements by tag name, by id or by class name. + +**_querySelector_**: can be used to select HTML element by its tag name, id or class. If the tag name is used it selects only the first element. + +```js +let firstTitle = document.querySelector('h1') // select the first available h2 element +let firstTitle = document.querySelector('#first-title') // select id with first-title +let firstTitle = document.querySelector('.title') // select the first available h2 element with class title +``` + +**_querySelectorAll_**: can be used to select html element by its tag name or class. It return a nodeList which is an array like object which support array methods. We can use **_for loop_** or **_forEach_** to loop through each nodeList elements. + +```js +const allTitles = document.querySelectorAll('h1') + +console.log(allTitles.length) // 4 +for (let i = 0; i < allTitles.length; i++) { + console.log(allTitles[i]) +} + +allTitles.forEach(title => console.log(title)) +const allTitles = document.querySelectorAll('.title') // the same goes for selecting using class +``` + +### Adding attribute + +An attribute is added in the opening tag of HTML which gives additional information about the element. Common HTML attributes: id, class, src, style, href,disabled, title, alt. Lets add id and class for the fourth title. + +```js +const titles = document.querySelectorAll('h1') +titles[3].class = 'title' +titles[3].id = 'fourth-title' +``` + +#### Adding attribute using setAttribute + +The **_setAttribute()_** method set any html attribute. It takes two parameters the type of the attribute and the name of the attribute. +Let's add class and id attribute for the fourth title. + +```js +const titles = document.querySelectorAll('h1') +titles[3].setAttribute('class', 'title') +titles[3].setAttribute('id', 'fourth-title') +``` + +#### Adding attribute without setAttribute + +We can use normal object setting method to set an attribute but this can not work for all elements. Some attributes are DOM object property and they can be set directly. For instance id and class + +```js +//another way to setting an attribute +titles[3].className = 'title' +titles[3].id = 'fourth-title' +``` + +#### Adding class using classList + +The class list method is a good method to append additional class. It does not override the original class if a class exists rather it adds additional class for the element. + +```js +//another way to setting an attribute: append the class, doesn't over ride +titles[3].classList.add('title', 'header-title') +``` + +#### Removing class using remove + +Similar to adding we can also remove class from an element. We can remove a specific class from an element. + +```js +//another way to setting an attribute: append the class, doesn't over ride +titles[3].classList.remove('title', 'header-title') +``` + +### Adding Text to HTML element + +An HTML is a build block of an opening tag, a closing tag and a text content. We can add a text content using the property _textContent_ or \*innerHTML. + +#### Adding Text content using textContent + +The _textContent_ property is used to add text to an HTML element. + +```js +const titles = document.querySelectorAll('h1') +titles[3].textContent = 'Fourth Title' +``` + +#### Adding Text Content using innHTML + +Most people get confused between _textContent_ and _innerHTML_. _textContent_ is meant to add text to an HTML element, however innerHTML can add a text or HTML element or elements as a child. + +##### Text Content + +We assign *textContent* HTML object property to a text + +```js +const titles = document.querySelectorAll('h1') +titles[3].textContent = 'Fourth Title' +``` + +##### Inner HTML + +We use innerHTML property when we like to replace or a completely new children content to a parent element. +It value we assign is going to be a string of HTML elements. + +```html + + + + JavaScript for Everyone:DOM + + +
+

Asabeneh Yetayeh challenges in 2020

+

30DaysOfJavaScript Challenge

+
    +
    + + + +``` + +The innerHTML property can allow us also to remove all the children of a parent element. Instead of using removeChild() I would recommend the following method. + +```html + + + + JavaScript for Everyone:DOM + + +
    +

    Asabeneh Yetayeh challenges in 2020

    +

    30DaysOfJavaScript Challenge

    +
      +
    • 30DaysOfPython Challenge Done
    • +
    • 30DaysOfJavaScript Challenge Ongoing
    • +
    • 30DaysOfReact Challenge Coming
    • +
    • 30DaysOfFullStack Challenge Coming
    • +
    • 30DaysOfDataAnalysis Challenge Coming
    • +
    • 30DaysOfReactNative Challenge Coming
    • +
    • 30DaysOfMachineLearning Challenge Coming
    • +
    +
    + + + +``` + +### Adding style + +#### Adding Style Color + +Let us add some style to our titles. If the element has even index we give it green color else red. + +```js +const titles = document.querySelectorAll('h1') +titles.forEach((title, i) => { + title.style.fontSize = '24px' // all titles will have 24px font size + if (i % 2 === 0) { + title.style.color = 'green' + } else { + title.style.color = 'red' + } +}) +``` + +#### Adding Style Background Color + +Let us add some style to our titles. If the element has even index we give it green color else red. + +```js +const titles = document.querySelectorAll('h1') +titles.forEach((title, i) => { + title.style.fontSize = '24px' // all titles will have 24px font size + if (i % 2 === 0) { + title.style.backgroundColor = 'green' + } else { + title.style.backgroundColor = 'red' + } +}) +``` + +#### Adding Style Font Size + +Let us add some style to our titles. If the element has even index we give it 20px else 30px + +```js +const titles = document.querySelectorAll('h1') +titles.forEach((title, i) => { + title.style.fontSize = '24px' // all titles will have 24px font size + if (i % 2 === 0) { + title.style.fontSize = '20px' + } else { + title.style.fontSize = '30px' + } +}) +``` + +As you have notice, the properties of css when we use it in JavaScript is going to be a camelCase. The following CSS properties change from background-color to backgroundColor, font-size to fontSize, font-family to fontFamily, margin-bottom to marginBottom. + +--- + +🌕 Now, you are fully charged with a super power, you have completed the most important and challenging part of the challenge and in general JavaScript. You learned DOM and now you have the capability to build and develop applications. Now do some exercises for your brain and for your muscle. + +## Exercises + +### Exercise: Level 1 + +1. Create an index.html file and put four p elements as above: Get the first paragraph by using **_document.querySelector(tagname)_** and tag name +2. Get get each of the the paragraph using **_document.querySelector('#id')_** and by their id +3. Get all the p as nodeList using **_document.querySelectorAll(tagname)_** and by their tag name +4. Loop through the nodeList and get the text content of each paragraph +5. Set a text content to paragraph the fourth paragraph,**_Fourth Paragraph_** +6. Set id and class attribute for all the paragraphs using different attribute setting methods + +### Exercise: Level 2 + +1. Change stye of each paragraph using JavaScript(eg. color, background, border, font-size, font-family) +1. Select all paragraphs and loop through each elements and give the first and third paragraph a color of green, and the second and the fourth paragraph a red color +1. Set text content, id and class to each paragraph + +### Exercise: Level 3 + +#### DOM: Mini project 1 + +1. Develop the following application, use the following HTML elements to get started with. You will get the same code on starter folder. Apply all the styles and functionality using JavaScript only. + + - The year color is changing every 1 second + - The date and time background color is changing every on seconds + - Completed challenge has background green + - Ongoing challenge has background yellow + - Coming challenges have background red + +```html + + + + + JavaScript for Everyone:DOM + + +
    +

    Asabeneh Yetayeh challenges in 2020

    +

    30DaysOfJavaScript Challenge

    +
      +
    • 30DaysOfPython Challenge Done
    • +
    • 30DaysOfJavaScript Challenge Ongoing
    • +
    • 30DaysOfReact Challenge Coming
    • +
    • 30DaysOfFullStack Challenge Coming
    • +
    • 30DaysOfDataAnalysis Challenge Coming
    • +
    • 30DaysOfReactNative Challenge Coming
    • +
    • 30DaysOfMachineLearning Challenge Coming
    • +
    +
    + + +``` + +![Project 1](../images/projects/dom_min_project_challenge_info_day_1.1.gif) + +![Project 2](../images/projects/dom_min_project_challenge_info_day_1.1.png) + +🎉 CONGRATULATIONS ! 🎉 + +[<< Day 20](../20_Day_Writing_clean_codes/20_day_writing_clean_codes.md) | [Day 22 >>](../22_Day_Manipulating_DOM_object/22_day_manipulating_DOM_object.md) diff --git a/21_Day_DOM/21_day_starter/dom_getting_elements_project_1.gif b/21_Day_DOM/21_day_starter/dom_getting_elements_project_1.gif new file mode 100644 index 0000000..0551771 Binary files /dev/null and b/21_Day_DOM/21_day_starter/dom_getting_elements_project_1.gif differ diff --git a/21_Day_DOM/21_day_starter/index.html b/21_Day_DOM/21_day_starter/index.html new file mode 100644 index 0000000..ad12ac6 --- /dev/null +++ b/21_Day_DOM/21_day_starter/index.html @@ -0,0 +1,26 @@ + + + + + 30DaysOfJavaScript:21 Day + + + +
    +

    Asabeneh Yetayeh challenges in 2020

    +

    30DaysOfJavaScript Challenge

    +
      +
    • 30DaysOfPython Challenge Done
    • +
    • 30DaysOfJavaScript Challenge Ongoing
    • +
    • 30DaysOfReact Challenge Coming
    • +
    • 30DaysOfFullStack Challenge Coming
    • +
    • 30DaysOfDataAnalysis Challenge Coming
    • +
    • 30DaysOfReactNative Challenge Coming
    • +
    • 30DaysOfMachineLearning Challenge Coming
    • +
    +
    + + + + + \ No newline at end of file diff --git a/21_Day_DOM/21_day_starter/scripts/main.js b/21_Day_DOM/21_day_starter/scripts/main.js new file mode 100644 index 0000000..e69de29 diff --git a/22_Day_Manipulating_DOM_object/22_day_manipulating_DOM_object.md b/22_Day_Manipulating_DOM_object/22_day_manipulating_DOM_object.md new file mode 100644 index 0000000..d9e4ad7 --- /dev/null +++ b/22_Day_Manipulating_DOM_object/22_day_manipulating_DOM_object.md @@ -0,0 +1,231 @@ +
    +

    30 Days Of JavaScript: Manipulating DOM Object

    + + + + + Twitter Follow + + +Author: +Asabeneh Yetayeh
    + January, 2020 +
    + +
    + +[<< Day 21](../21_Day_DOM/21_day_dom.md) | [Day 23 >>](../23_Day_Event_listeners/23_day_event_listeners.md) + +![Thirty Days Of JavaScript](../images/banners/day_1_22.png) +- [Day 22](#day-22) + - [DOM(Document Object Model)-Day 2](#domdocument-object-model-day-2) + - [Creating an Element](#creating-an-element) + - [Creating elements](#creating-elements) + - [Appending child to a parent element](#appending-child-to-a-parent-element) + - [Removing a child element from a parent node](#removing-a-child-element-from-a-parent-node) + - [Exercises](#exercises) + - [Exercises: Level 1](#exercises-level-1) + - [Exercises: Level 2](#exercises-level-2) + - [Exercises: Level 3](#exercises-level-3) + +# Day 22 + +## DOM(Document Object Model)-Day 2 + +### Creating an Element + +To create an HTML element we use tag name. Creating an HTML element using JavaScript is very simple and straight forward. We use the method _document.createElement()_. The method takes an HTML element tag name as a string parameter. + +```js +// syntax +document.createElement('tagname') +``` + +```html + + + + + Document Object Model:30 Days Of JavaScript + + + + + + + + +``` + +### Creating elements + +To create multiple elements we should use loop. Using loop we can create as many HTML elements as we want. +After we create the element we can assign value to the different properties of the HTML object. + +```html + + + + + Document Object Model:30 Days Of JavaScript + + + + + + + + +``` + +### Appending child to a parent element + +To see a created element on the HTML document we should append it to the parent as a child element. We can access the HTML document body using *document.body*. The *document.body* support the *appendChild()* method. See the example below. + +```html + + + + + Document Object Model:30 Days Of JavaScript + + + + + + + +``` + +### Removing a child element from a parent node + +After creating an HTML, we may want to remove element or elements and we can use the *removeChild()* method. + +**Example:** + +```html + + + + + Document Object Model:30 Days Of JavaScript + + + +

    Removing child Node

    +

    Asabeneh Yetayeh challenges in 2020

    +
      +
    • 30DaysOfPython Challenge Done
    • +
    • 30DaysOfJavaScript Challenge Done
    • +
    • 30DaysOfReact Challenge Coming
    • +
    • 30DaysOfFullStack Challenge Coming
    • +
    • 30DaysOfDataAnalysis Challenge Coming
    • +
    • 30DaysOfReactNative Challenge Coming
    • +
    • 30DaysOfMachineLearning Challenge Coming
    • +
    + + + + + +``` + +As we have see in the previous section there is a better way to eliminate all the inner HTML elements or the children of a parent element using the method *innerHTML* properties. + +```html + + + + + Document Object Model:30 Days Of JavaScript + + + +

    Removing child Node

    +

    Asabeneh Yetayeh challenges in 2020

    +
      +
    • 30DaysOfPython Challenge Done
    • +
    • 30DaysOfJavaScript Challenge Done
    • +
    • 30DaysOfReact Challenge Coming
    • +
    • 30DaysOfFullStack Challenge Coming
    • +
    • 30DaysOfDataAnalysis Challenge Coming
    • +
    • 30DaysOfReactNative Challenge Coming
    • +
    • 30DaysOfMachineLearning Challenge Coming
    • +
    + + + + + +``` + +The above snippet of code cleared all the child elements. + +--- + +🌕 You are so special, you are progressing everyday. Now, you knew how to destroy a created DOM element when it is needed. You learned DOM and now you have the capability to build and develop applications. You are left with only eight days to your way to greatness. Now do some exercises for your brain and for your muscle. + +## Exercises + +### Exercises: Level 1 + +1. Create a div container on HTML document and create 100 to 100 numbers dynamically and append to the container div. + - Even numbers background is green + - Odd numbers background is yellow + - Prime numbers background is red + +![Number Generator](./../images/projects/dom_min_project_day_number_generators_2.1.png) + +### Exercises: Level 2 + +1. Use the countries array to display all the countries.See the design + +![World Countries List](./../images/projects/dom_min_project_countries_aray_day_2.2.png) + +### Exercises: Level 3 + +Check the requirement of this project from both images(jpg and gif). All the data and CSS has been implemented using JavaScript only. The data is found on starter folder project_3. The drop down button has been created using [*details*](https://www.w3schools.com/tags/tag_details.asp) HTML element. + +![Challenge Information](./../images/projects/dom_mini_project_challenge_info_day_2.3.gif) + +![Challenge Information](./../images/projects/dom_mini_project_challenge_info_day_2.3.png) + +🎉 CONGRATULATIONS ! 🎉 + +[<< Day 21](../21_Day_DOM/21_day_dom.md) | [Day 23 >>](../23_Day_Event_listeners/23_day_event_listeners.md) \ No newline at end of file diff --git a/22_Day_Manipulating_DOM_object/22_day_starters/design/dom_min_project_challenge_info_day_1.1.gif b/22_Day_Manipulating_DOM_object/22_day_starters/design/dom_min_project_challenge_info_day_1.1.gif new file mode 100644 index 0000000..0551771 Binary files /dev/null and b/22_Day_Manipulating_DOM_object/22_day_starters/design/dom_min_project_challenge_info_day_1.1.gif differ diff --git a/22_Day_Manipulating_DOM_object/22_day_starters/design/dom_min_project_countries_aray_day_2.2.png b/22_Day_Manipulating_DOM_object/22_day_starters/design/dom_min_project_countries_aray_day_2.2.png new file mode 100644 index 0000000..ca0e344 Binary files /dev/null and b/22_Day_Manipulating_DOM_object/22_day_starters/design/dom_min_project_countries_aray_day_2.2.png differ diff --git a/22_Day_Manipulating_DOM_object/22_day_starters/design/dom_min_project_day_number_generators_2.1.png b/22_Day_Manipulating_DOM_object/22_day_starters/design/dom_min_project_day_number_generators_2.1.png new file mode 100644 index 0000000..d69a6c2 Binary files /dev/null and b/22_Day_Manipulating_DOM_object/22_day_starters/design/dom_min_project_day_number_generators_2.1.png differ diff --git a/22_Day_Manipulating_DOM_object/22_day_starters/design/dom_mini_project_challenge_info_day_2.3.gif b/22_Day_Manipulating_DOM_object/22_day_starters/design/dom_mini_project_challenge_info_day_2.3.gif new file mode 100644 index 0000000..571ea6f Binary files /dev/null and b/22_Day_Manipulating_DOM_object/22_day_starters/design/dom_mini_project_challenge_info_day_2.3.gif differ diff --git a/22_Day_Manipulating_DOM_object/22_day_starters/design/dom_mini_project_challenge_info_day_2.3.png b/22_Day_Manipulating_DOM_object/22_day_starters/design/dom_mini_project_challenge_info_day_2.3.png new file mode 100644 index 0000000..3387bea Binary files /dev/null and b/22_Day_Manipulating_DOM_object/22_day_starters/design/dom_mini_project_challenge_info_day_2.3.png differ diff --git a/22_Day_Manipulating_DOM_object/22_day_starters/project_1/index.html b/22_Day_Manipulating_DOM_object/22_day_starters/project_1/index.html new file mode 100644 index 0000000..6855059 --- /dev/null +++ b/22_Day_Manipulating_DOM_object/22_day_starters/project_1/index.html @@ -0,0 +1,22 @@ + + + + + 30DaysOfJavaScript:22 Day: Number Generator + + + +

    Number Generator

    +

    30DaysOfJavaScript:DOM Day 2

    +

    Author: Asabeneh Yetayeh

    +
    + +
    + + + + + + + + \ No newline at end of file diff --git a/22_Day_Manipulating_DOM_object/22_day_starters/project_1/scripts/main.js b/22_Day_Manipulating_DOM_object/22_day_starters/project_1/scripts/main.js new file mode 100644 index 0000000..c6045c8 --- /dev/null +++ b/22_Day_Manipulating_DOM_object/22_day_starters/project_1/scripts/main.js @@ -0,0 +1,2 @@ +console.log(countries) +alert('Open the console and check if the countries has been loaded') \ No newline at end of file diff --git a/22_Day_Manipulating_DOM_object/22_day_starters/project_2/data/countries.js b/22_Day_Manipulating_DOM_object/22_day_starters/project_2/data/countries.js new file mode 100644 index 0000000..e57b005 --- /dev/null +++ b/22_Day_Manipulating_DOM_object/22_day_starters/project_2/data/countries.js @@ -0,0 +1,195 @@ +const countries = [ + 'Afghanistan', + 'Albania', + 'Algeria', + 'Andorra', + 'Angola', + 'Antigua and Barbuda', + 'Argentina', + 'Armenia', + 'Australia', + 'Austria', + 'Azerbaijan', + 'Bahamas', + 'Bahrain', + 'Bangladesh', + 'Barbados', + 'Belarus', + 'Belgium', + 'Belize', + 'Benin', + 'Bhutan', + 'Bolivia', + 'Bosnia and Herzegovina', + 'Botswana', + 'Brazil', + 'Brunei', + 'Bulgaria', + 'Burkina Faso', + 'Burundi', + 'Cambodia', + 'Cameroon', + 'Canada', + 'Cape Verde', + 'Central African Republic', + 'Chad', + 'Chile', + 'China', + 'Colombi', + 'Comoros', + 'Congo (Brazzaville)', + 'Congo', + 'Costa Rica', + "Cote d'Ivoire", + 'Croatia', + 'Cuba', + 'Cyprus', + 'Czech Republic', + 'Denmark', + 'Djibouti', + 'Dominica', + 'Dominican Republic', + 'East Timor (Timor Timur)', + 'Ecuador', + 'Egypt', + 'El Salvador', + 'Equatorial Guinea', + 'Eritrea', + 'Estonia', + 'Ethiopia', + 'Fiji', + 'Finland', + 'France', + 'Gabon', + 'Gambia, The', + 'Georgia', + 'Germany', + 'Ghana', + 'Greece', + 'Grenada', + 'Guatemala', + 'Guinea', + 'Guinea-Bissau', + 'Guyana', + 'Haiti', + 'Honduras', + 'Hungary', + 'Iceland', + 'India', + 'Indonesia', + 'Iran', + 'Iraq', + 'Ireland', + 'Israel', + 'Italy', + 'Jamaica', + 'Japan', + 'Jordan', + 'Kazakhstan', + 'Kenya', + 'Kiribati', + 'Korea, North', + 'Korea, South', + 'Kuwait', + 'Kyrgyzstan', + 'Laos', + 'Latvia', + 'Lebanon', + 'Lesotho', + 'Liberia', + 'Libya', + 'Liechtenstein', + 'Lithuania', + 'Luxembourg', + 'Macedonia', + 'Madagascar', + 'Malawi', + 'Malaysia', + 'Maldives', + 'Mali', + 'Malta', + 'Marshall Islands', + 'Mauritania', + 'Mauritius', + 'Mexico', + 'Micronesia', + 'Moldova', + 'Monaco', + 'Mongolia', + 'Morocco', + 'Mozambique', + 'Myanmar', + 'Namibia', + 'Nauru', + 'Nepal', + 'Netherlands', + 'New Zealand', + 'Nicaragua', + 'Niger', + 'Nigeria', + 'Norway', + 'Oman', + 'Pakistan', + 'Palau', + 'Panama', + 'Papua New Guinea', + 'Paraguay', + 'Peru', + 'Philippines', + 'Poland', + 'Portugal', + 'Qatar', + 'Romania', + 'Russia', + 'Rwanda', + 'Saint Kitts and Nevis', + 'Saint Lucia', + 'Saint Vincent', + 'Samoa', + 'San Marino', + 'Sao Tome and Principe', + 'Saudi Arabia', + 'Senegal', + 'Serbia and Montenegro', + 'Seychelles', + 'Sierra Leone', + 'Singapore', + 'Slovakia', + 'Slovenia', + 'Solomon Islands', + 'Somalia', + 'South Africa', + 'Spain', + 'Sri Lanka', + 'Sudan', + 'Suriname', + 'Swaziland', + 'Sweden', + 'Switzerland', + 'Syria', + 'Taiwan', + 'Tajikistan', + 'Tanzania', + 'Thailand', + 'Togo', + 'Tonga', + 'Trinidad and Tobago', + 'Tunisia', + 'Turkey', + 'Turkmenistan', + 'Tuvalu', + 'Uganda', + 'Ukraine', + 'United Arab Emirates', + 'United Kingdom', + 'United States', + 'Uruguay', + 'Uzbekistan', + 'Vanuatu', + 'Vatican City', + 'Venezuela', + 'Vietnam', + 'Yemen', + 'Zambia', + 'Zimbabwe' +] diff --git a/22_Day_Manipulating_DOM_object/22_day_starters/project_2/index.html b/22_Day_Manipulating_DOM_object/22_day_starters/project_2/index.html new file mode 100644 index 0000000..85b7c80 --- /dev/null +++ b/22_Day_Manipulating_DOM_object/22_day_starters/project_2/index.html @@ -0,0 +1,31 @@ + + + + + 30DaysOfJavaScript:22 Day: World Countries List + + + +
    +

    World Countries List

    + +

    +

    30DaysOfJavaScript:DOM-Day-2

    +

    Author: Asabeneh Yetayeh

    + +
    + +
    +
    + +
    +
    + + + + + + + + + \ No newline at end of file diff --git a/22_Day_Manipulating_DOM_object/22_day_starters/project_2/scripts/main.js b/22_Day_Manipulating_DOM_object/22_day_starters/project_2/scripts/main.js new file mode 100644 index 0000000..9d06661 --- /dev/null +++ b/22_Day_Manipulating_DOM_object/22_day_starters/project_2/scripts/main.js @@ -0,0 +1 @@ +console.log(countries) diff --git a/22_Day_Manipulating_DOM_object/22_day_starters/project_3/data/challenges_info.js b/22_Day_Manipulating_DOM_object/22_day_starters/project_3/data/challenges_info.js new file mode 100644 index 0000000..c0dc9e4 --- /dev/null +++ b/22_Day_Manipulating_DOM_object/22_day_starters/project_3/data/challenges_info.js @@ -0,0 +1,198 @@ +const asabenehChallenges2020 = { + description: 'Asabeneh Yetayeh challenges', + challengeTitle: 'Asabeneh Yetayeh challenges', + challengeSubtitle: '30DaysOfJavaScript Challenge', + challengeYear: 2020, + keywords: [ + 'HTML', + 'HTML5', + 'CSS', + 'CSS3', + 'JS', + 'JavaScript', + 'ES6', + 'Promise', + 'async await', + 'Database', + 'React', + 'React Hooks', + 'Context API', + 'React Router', + 'Web Storage', + 'localStorage', + 'sessionStorage', + 'Redux', + 'Node', + 'MongoDB', + 'SQL', + 'API', + 'DOM', + 'data science', + 'MERN', + 'Python', + 'Flask', + 'Statistics', + 'Linear Algebra', + 'Numpy', + 'Pandas', + 'Scipy', + 'Scikit-learn', + 'Visualization', + 'D3.js' + ], + author: { + firstName: 'Asabeneh', + lastName: 'Yetayeh', + titles: [ + ['🌱', 'Educator'], + ['💻', 'Programmer'], + ['🌐', 'Developer'], + ['🔥', 'Motivator'], + ['📔', 'Content Creator'] + ], + qualifications: [ + 'MSc. Computer Science Ongoing', + 'BSc. Information and Communication Eng.', + 'MSc. Food Technology', + 'BSc.Food Technology' + ], + socialLinks: [ + { + social: 'LinkedIn', + url: 'https://www.linkedin.com/in/asabeneh/', + fontawesomeIcon: '' + }, + { + social: 'Twitter', + url: 'https://twitter.com/Asabeneh', + fontawesomeIcon: '' + }, + { + social: 'Github', + fontawesomeIcon: '', + url: 'https://github.com/Asabeneh' + }, + { + social: 'DEV.to', + fontawesomeIcon: '', + url: 'https://dev.to/asabeneh' + } + ], + skills: [ + 'Web Development', + 'Data Analysis', + 'Data Visualization', + 'Programming', + 'Databases', + 'Developing API' + ], + bio: + '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.' + }, + challenges: [ + { + name: '30 Days Of Python', + topics: [ + 'Python', + 'Flask', + 'Numpy', + 'Pandas', + 'Statistics', + 'API', + 'MongoDB' + ], + days: 30, + status: 'Done', + questions: 'Above 500', + projects: 'Two', + interviewQns: '', + githubUrl: 'https://github.com/Asabeneh/30-Days-Of-Python' + }, + { + name: '30 Days Of JavaScript', + topics: ['JavaScript', 'ES6', 'Promise', 'async and await', 'DOM'], + days: 30, + status: 'Ongoing', + questions: 'Above 500', + projects: 'About 30', + interviewQns: '', + githubUrl: 'https://github.com/Asabeneh/30DaysOfJavaScript' + }, + { + name: '30 Days Of HTML & CSS', + topics: ['CSS', 'Flex', 'Grid', 'CSS Animation'], + days: 30, + status: 'Coming', + questions: 'Above 500', + projects: 'Two', + interviewQns: '', + githubUrl: '' + }, + { + name: '30 Days Of React', + topics: [ + 'React', + 'React Router', + 'Redux', + 'Context API', + 'React Hooks', + 'MERN' + ], + days: 30, + status: 'Coming', + questions: '', + projects: '', + interviewQns: '', + githubUrl: '' + }, + { + name: '30 Days Of ReactNative', + topics: ['ReactNative', 'Redux'], + days: 30, + status: 'Coming', + questions: '', + projects: 'Two', + interviewQns: '', + githubUrl: '' + }, + { + name: '30 Days Of Fullstack', + topics: ['React', 'Redux', 'MongoDB', 'Node', 'MERN'], + days: 30, + status: 'Coming', + questions: '', + projects: '', + interviewQns: '', + githubUrl: '' + }, + { + name: '30 Days Of Data Analysis', + topics: ['Python', 'Numpy', 'Pandas', 'Statistics', 'Visualization'], + days: 30, + status: 'Coming', + questions: '', + projects: '', + interviewQns: '', + githubUrl: '' + }, + { + name: '30 Days Of Machine Learning', + topics: [ + 'Python', + 'Numpy', + 'Pandas', + 'Scikit-learn', + 'Scipy', + 'Linear Algebra', + 'Statistics', + 'Visualization' + ], + days: 30, + status: 'Coming', + questions: '', + projects: '', + interviewQns: '', + githubUrl: '' + } + ] +} diff --git a/22_Day_Manipulating_DOM_object/22_day_starters/project_3/index.html b/22_Day_Manipulating_DOM_object/22_day_starters/project_3/index.html new file mode 100644 index 0000000..054cf9c --- /dev/null +++ b/22_Day_Manipulating_DOM_object/22_day_starters/project_3/index.html @@ -0,0 +1,19 @@ + + + + + 30DaysOfJavaScript:22 Day: Challenge Info + + + +
    +
    + + + + + + + + + \ No newline at end of file diff --git a/22_Day_Manipulating_DOM_object/22_day_starters/project_3/scripts/main.js b/22_Day_Manipulating_DOM_object/22_day_starters/project_3/scripts/main.js new file mode 100644 index 0000000..fa02efd --- /dev/null +++ b/22_Day_Manipulating_DOM_object/22_day_starters/project_3/scripts/main.js @@ -0,0 +1 @@ +console.log(asabenehChallenges2020) \ No newline at end of file diff --git a/23_Day_Event_listeners/23_day_event_listeners.md b/23_Day_Event_listeners/23_day_event_listeners.md new file mode 100644 index 0000000..1100593 --- /dev/null +++ b/23_Day_Event_listeners/23_day_event_listeners.md @@ -0,0 +1,332 @@ +
    +

    30 Days Of JavaScript: Event Listeners

    + + + + + Twitter Follow + + +Author: +Asabeneh Yetayeh
    + January, 2020 +
    + +
    + +[<< Day 22](../22_Day_Manipulating_DOM_object/22_day_manipulating_DOM_object.md) | [Day 24 >>](../24_Day_Project_solar_system/24_day_project_solar_system.md) + +![Thirty Days Of JavaScript](../images/banners/day_1_23.png) + +- [Day 22](#day-22) + - [DOM(Document Object Model)-Day 3](#domdocument-object-model-day-3) + - [Event Listeners](#event-listeners) + - [Click](#click) + - [Double Click](#double-click) + - [Mouse enter](#mouse-enter) + - [Getting value from an input element](#getting-value-from-an-input-element) + - [input value](#input-value) + - [input event and change](#input-event-and-change) + - [blur event](#blur-event) + - [keypress, keydow and keyup](#keypress-keydow-and-keyup) + - [Exercises](#exercises) + - [Exercise: Level 1](#exercise-level-1) + +# Day 22 + +## DOM(Document Object Model)-Day 3 + +### Event Listeners + +Common HTML events:onclick, onchange, onmouseover, onmouseout, onkeydown, onkeyup, onload. +We can add event listener method to any DOM object. We use **_addEventListener()_** method to listen different event types on HTML elements. The _addEventListener()_ method takes two arguments, an event listener and a callback function. + +```js +selectedElement.addEventListener('eventlistner', function(e) { + // the activity you want to occur after the event will be in here +}) +// or + +selectedElement.addEventListener('eventlistner', e => { + // the activity you want to occur after the event will be in here +}) +``` + +#### Click + +To attach an event listener to an element, first we select the element then we attach the addEventListener method. The event listener takes event type and callback functions as argument. + +The following is an example of click type event. + +**Example: click** + +```html + + + + Document Object Model + + + + + + + + +``` + +An event can be also attached directly to the HTML element as inline script. + +**Example: onclick** + +```html + + + + Document Object Model + + + + + + + +``` + +#### Double Click + +To attach an event listener to an element, first we select the element then we attach the addEventListener method. The event listener takes event type and callback functions as argument. + +The following is an example of click type event. +**Example: dblclick** + +```html + + + + Document Object Model + + + + + + + +``` + +#### Mouse enter + +To attach an event listener to an element, first we select the element then we attach the addEventListener method. The event listener takes event type and callback functions as argument. + +The following is an example of click type event. + +**Example: mouseenter** + +```html + + + + Document Object Model + + + + + + + +``` + +By now you are familiar with addEventListen method and how to attach event listener. There are many types of event listeners. But in this challenge we will focus the most common important events. +List of events: + +- click - when the element clicked +- dbclick - when the element double clicked +- mouseenter - when the mouse point enter to the element +- mouseleave - when the mouse pointer leave the element +- mousemove - when the mouse pointer move on the element +- mouseover - when the mouse pointer move on the element +- mouseout -when the mouse pointer out from the element +- input -when value enter to input field +- change -when value change on input field +- blur -when the element is not focused +- keydown - when a key is down +- keyup - when a key is up +- keypress - when we press any key +- onload - when the browser has finished loading a page + +Test the above event types by replacing event type in the above snippet code. + +### Getting value from an input element + +We usually fill forms and forms accept data. Form fields are created using input HTML element. Let us build a small application which allow us to calculate body mas index of a person using two input fields, one button and one p tag. + +### input value + +```html + + + + Document Object Model:30 Days Of JavaScript + + + +

    Body Mass Index Calculator

    + + + + + + + + +``` + +#### input event and change + +In the above example, we managed to get input values from two input fields by clicking button. How about if we want to get value without click the button. We can use the _change_ or _input_ event type to get data right away from the input field when the field is on focus. Let us see how we will handle that. + +```html + + + + Document Object Model:30 Days Of JavaScript + + + +

    Data Binding using input or change event

    + + +

    + + + + +``` + +#### blur event + +In contrast to _input_ or _change_, the _blur_ event occur when the input field is not on focus. + +```js + + + + + Document Object Model:30 Days Of JavaScript + + + +

    Giving feedback using blur event

    + + +

    + + + + + +``` + +#### keypress, keydow and keyup + +We can access all the key numbers of the keyboard using different event listener types. Let us use keypress and get the keyCode of each keyboard keys. + +```html + + + + Document Object Model:30 Days Of JavaScript + + + +

    Key events: Press any key

    + + + + +``` + +--- + +🌕 You are so special, you are progressing everyday. Now, you knew how handle any kind of DOM events. . You are left with only seven days to your way to greatness. Now do some exercises for your brain and for your muscle. + +## Exercises + +### Exercise: Level 1 + +1. Generating numbers and marking evens, odds and prime numbers with three different colors. See the image below. + +![Number Generator](./../images/projects/dom_min_project_number_generator_day_3.1.gif) + +1. Generating the keyboard code code using even listener. The image below. + +![Keyboard key](./../images/projects/dom_min_project_keycode_day_3.2.gif) + +🎉 CONGRATULATIONS ! 🎉 + +[<< Day 22](../22_Day_Manipulating_DOM_object/22_day_manipulating_DOM_object.md) | [Day 24 >>](../24_Day_Project_solar_system/24_day_project_solar_system.md) diff --git a/23_Day_Event_listeners/23_day_starters/design/data/countries_data.js b/23_Day_Event_listeners/23_day_starters/design/data/countries_data.js new file mode 100644 index 0000000..92acddd --- /dev/null +++ b/23_Day_Event_listeners/23_day_starters/design/data/countries_data.js @@ -0,0 +1,2013 @@ +const countries = [ + { + name: 'Afghanistan', + capital: 'Kabul', + languages: ['Pashto', 'Uzbek', 'Turkmen'], + population: 27657145, + flag: 'https://restcountries.eu/data/afg.svg', + currency: 'Afghan afghani' + }, + { + name: 'Åland Islands', + capital: 'Mariehamn', + languages: ['Swedish'], + population: 28875, + flag: 'https://restcountries.eu/data/ala.svg', + currency: 'Euro' + }, + { + name: 'Albania', + capital: 'Tirana', + languages: ['Albanian'], + population: 2886026, + flag: 'https://restcountries.eu/data/alb.svg', + currency: 'Albanian lek' + }, + { + name: 'Algeria', + capital: 'Algiers', + languages: ['Arabic'], + population: 40400000, + flag: 'https://restcountries.eu/data/dza.svg', + currency: 'Algerian dinar' + }, + { + name: 'American Samoa', + capital: 'Pago Pago', + languages: ['English', 'Samoan'], + population: 57100, + flag: 'https://restcountries.eu/data/asm.svg', + currency: 'United State Dollar' + }, + { + name: 'Andorra', + capital: 'Andorra la Vella', + languages: ['Catalan'], + population: 78014, + flag: 'https://restcountries.eu/data/and.svg', + currency: 'Euro' + }, + { + name: 'Angola', + capital: 'Luanda', + languages: ['Portuguese'], + population: 25868000, + flag: 'https://restcountries.eu/data/ago.svg', + currency: 'Angolan kwanza' + }, + { + name: 'Anguilla', + capital: 'The Valley', + languages: ['English'], + population: 13452, + flag: 'https://restcountries.eu/data/aia.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Antarctica', + capital: '', + languages: ['English', 'Russian'], + population: 1000, + flag: 'https://restcountries.eu/data/ata.svg', + currency: 'Australian dollar' + }, + { + name: 'Antigua and Barbuda', + capital: "Saint John's", + languages: ['English'], + population: 86295, + flag: 'https://restcountries.eu/data/atg.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Argentina', + capital: 'Buenos Aires', + languages: ['Spanish', 'Guaraní'], + population: 43590400, + flag: 'https://restcountries.eu/data/arg.svg', + currency: 'Argentine peso' + }, + { + name: 'Armenia', + capital: 'Yerevan', + languages: ['Armenian', 'Russian'], + population: 2994400, + flag: 'https://restcountries.eu/data/arm.svg', + currency: 'Armenian dram' + }, + { + name: 'Aruba', + capital: 'Oranjestad', + languages: ['Dutch', '(Eastern) Punjabi'], + population: 107394, + flag: 'https://restcountries.eu/data/abw.svg', + currency: 'Aruban florin' + }, + { + name: 'Australia', + capital: 'Canberra', + languages: ['English'], + population: 24117360, + flag: 'https://restcountries.eu/data/aus.svg', + currency: 'Australian dollar' + }, + { + name: 'Austria', + capital: 'Vienna', + languages: ['German'], + population: 8725931, + flag: 'https://restcountries.eu/data/aut.svg', + currency: 'Euro' + }, + { + name: 'Azerbaijan', + capital: 'Baku', + languages: ['Azerbaijani'], + population: 9730500, + flag: 'https://restcountries.eu/data/aze.svg', + currency: 'Azerbaijani manat' + }, + { + name: 'Bahamas', + capital: 'Nassau', + languages: ['English'], + population: 378040, + flag: 'https://restcountries.eu/data/bhs.svg', + currency: 'Bahamian dollar' + }, + { + name: 'Bahrain', + capital: 'Manama', + languages: ['Arabic'], + population: 1404900, + flag: 'https://restcountries.eu/data/bhr.svg', + currency: 'Bahraini dinar' + }, + { + name: 'Bangladesh', + capital: 'Dhaka', + languages: ['Bengali'], + population: 161006790, + flag: 'https://restcountries.eu/data/bgd.svg', + currency: 'Bangladeshi taka' + }, + { + name: 'Barbados', + capital: 'Bridgetown', + languages: ['English'], + population: 285000, + flag: 'https://restcountries.eu/data/brb.svg', + currency: 'Barbadian dollar' + }, + { + name: 'Belarus', + capital: 'Minsk', + languages: ['Belarusian', 'Russian'], + population: 9498700, + flag: 'https://restcountries.eu/data/blr.svg', + currency: 'New Belarusian ruble' + }, + { + name: 'Belgium', + capital: 'Brussels', + languages: ['Dutch', 'French', 'German'], + population: 11319511, + flag: 'https://restcountries.eu/data/bel.svg', + currency: 'Euro' + }, + { + name: 'Belize', + capital: 'Belmopan', + languages: ['English', 'Spanish'], + population: 370300, + flag: 'https://restcountries.eu/data/blz.svg', + currency: 'Belize dollar' + }, + { + name: 'Benin', + capital: 'Porto-Novo', + languages: ['French'], + population: 10653654, + flag: 'https://restcountries.eu/data/ben.svg', + currency: 'West African CFA franc' + }, + { + name: 'Bermuda', + capital: 'Hamilton', + languages: ['English'], + population: 61954, + flag: 'https://restcountries.eu/data/bmu.svg', + currency: 'Bermudian dollar' + }, + { + name: 'Bhutan', + capital: 'Thimphu', + languages: ['Dzongkha'], + population: 775620, + flag: 'https://restcountries.eu/data/btn.svg', + currency: 'Bhutanese ngultrum' + }, + { + name: 'Bolivia (Plurinational State of)', + capital: 'Sucre', + languages: ['Spanish', 'Aymara', 'Quechua'], + population: 10985059, + flag: 'https://restcountries.eu/data/bol.svg', + currency: 'Bolivian boliviano' + }, + { + name: 'Bonaire, Sint Eustatius and Saba', + capital: 'Kralendijk', + languages: ['Dutch'], + population: 17408, + flag: 'https://restcountries.eu/data/bes.svg', + currency: 'United States dollar' + }, + { + name: 'Bosnia and Herzegovina', + capital: 'Sarajevo', + languages: ['Bosnian', 'Croatian', 'Serbian'], + population: 3531159, + flag: 'https://restcountries.eu/data/bih.svg', + currency: 'Bosnia and Herzegovina convertible mark' + }, + { + name: 'Botswana', + capital: 'Gaborone', + languages: ['English', 'Tswana'], + population: 2141206, + flag: 'https://restcountries.eu/data/bwa.svg', + currency: 'Botswana pula' + }, + { + name: 'Bouvet Island', + capital: '', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 0, + flag: 'https://restcountries.eu/data/bvt.svg', + currency: 'Norwegian krone' + }, + { + name: 'Brazil', + capital: 'Brasília', + languages: ['Portuguese'], + population: 206135893, + flag: 'https://restcountries.eu/data/bra.svg', + currency: 'Brazilian real' + }, + { + name: 'British Indian Ocean Territory', + capital: 'Diego Garcia', + languages: ['English'], + population: 3000, + flag: 'https://restcountries.eu/data/iot.svg', + currency: 'United States dollar' + }, + { + name: 'United States Minor Outlying Islands', + capital: '', + languages: ['English'], + population: 300, + flag: 'https://restcountries.eu/data/umi.svg', + currency: 'United States Dollar' + }, + { + name: 'Virgin Islands (British)', + capital: 'Road Town', + languages: ['English'], + population: 28514, + flag: 'https://restcountries.eu/data/vgb.svg', + currency: '[D]' + }, + { + name: 'Virgin Islands (U.S.)', + capital: 'Charlotte Amalie', + languages: ['English'], + population: 114743, + flag: 'https://restcountries.eu/data/vir.svg', + currency: 'United States dollar' + }, + { + name: 'Brunei Darussalam', + capital: 'Bandar Seri Begawan', + languages: ['Malay'], + population: 411900, + flag: 'https://restcountries.eu/data/brn.svg', + currency: 'Brunei dollar' + }, + { + name: 'Bulgaria', + capital: 'Sofia', + languages: ['Bulgarian'], + population: 7153784, + flag: 'https://restcountries.eu/data/bgr.svg', + currency: 'Bulgarian lev' + }, + { + name: 'Burkina Faso', + capital: 'Ouagadougou', + languages: ['French', 'Fula'], + population: 19034397, + flag: 'https://restcountries.eu/data/bfa.svg', + currency: 'West African CFA franc' + }, + { + name: 'Burundi', + capital: 'Bujumbura', + languages: ['French', 'Kirundi'], + population: 10114505, + flag: 'https://restcountries.eu/data/bdi.svg', + currency: 'Burundian franc' + }, + { + name: 'Cambodia', + capital: 'Phnom Penh', + languages: ['Khmer'], + population: 15626444, + flag: 'https://restcountries.eu/data/khm.svg', + currency: 'Cambodian riel' + }, + { + name: 'Cameroon', + capital: 'Yaoundé', + languages: ['English', 'French'], + population: 22709892, + flag: 'https://restcountries.eu/data/cmr.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Canada', + capital: 'Ottawa', + languages: ['English', 'French'], + population: 36155487, + flag: 'https://restcountries.eu/data/can.svg', + currency: 'Canadian dollar' + }, + { + name: 'Cabo Verde', + capital: 'Praia', + languages: ['Portuguese'], + population: 531239, + flag: 'https://restcountries.eu/data/cpv.svg', + currency: 'Cape Verdean escudo' + }, + { + name: 'Cayman Islands', + capital: 'George Town', + languages: ['English'], + population: 58238, + flag: 'https://restcountries.eu/data/cym.svg', + currency: 'Cayman Islands dollar' + }, + { + name: 'Central African Republic', + capital: 'Bangui', + languages: ['French', 'Sango'], + population: 4998000, + flag: 'https://restcountries.eu/data/caf.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chad', + capital: "N'Djamena", + languages: ['French', 'Arabic'], + population: 14497000, + flag: 'https://restcountries.eu/data/tcd.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chile', + capital: 'Santiago', + languages: ['Spanish'], + population: 18191900, + flag: 'https://restcountries.eu/data/chl.svg', + currency: 'Chilean peso' + }, + { + name: 'China', + capital: 'Beijing', + languages: ['Chinese'], + population: 1377422166, + flag: 'https://restcountries.eu/data/chn.svg', + currency: 'Chinese yuan' + }, + { + name: 'Christmas Island', + capital: 'Flying Fish Cove', + languages: ['English'], + population: 2072, + flag: 'https://restcountries.eu/data/cxr.svg', + currency: 'Australian dollar' + }, + { + name: 'Cocos (Keeling) Islands', + capital: 'West Island', + languages: ['English'], + population: 550, + flag: 'https://restcountries.eu/data/cck.svg', + currency: 'Australian dollar' + }, + { + name: 'Colombia', + capital: 'Bogotá', + languages: ['Spanish'], + population: 48759958, + flag: 'https://restcountries.eu/data/col.svg', + currency: 'Colombian peso' + }, + { + name: 'Comoros', + capital: 'Moroni', + languages: ['Arabic', 'French'], + population: 806153, + flag: 'https://restcountries.eu/data/com.svg', + currency: 'Comorian franc' + }, + { + name: 'Congo', + capital: 'Brazzaville', + languages: ['French', 'Lingala'], + population: 4741000, + flag: 'https://restcountries.eu/data/cog.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Congo (Democratic Republic of the)', + capital: 'Kinshasa', + languages: ['French', 'Lingala', 'Kongo', 'Swahili', 'Luba-Katanga'], + population: 85026000, + flag: 'https://restcountries.eu/data/cod.svg', + currency: 'Congolese franc' + }, + { + name: 'Cook Islands', + capital: 'Avarua', + languages: ['English'], + population: 18100, + flag: 'https://restcountries.eu/data/cok.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Costa Rica', + capital: 'San José', + languages: ['Spanish'], + population: 4890379, + flag: 'https://restcountries.eu/data/cri.svg', + currency: 'Costa Rican colón' + }, + { + name: 'Croatia', + capital: 'Zagreb', + languages: ['Croatian'], + population: 4190669, + flag: 'https://restcountries.eu/data/hrv.svg', + currency: 'Croatian kuna' + }, + { + name: 'Cuba', + capital: 'Havana', + languages: ['Spanish'], + population: 11239004, + flag: 'https://restcountries.eu/data/cub.svg', + currency: 'Cuban convertible peso' + }, + { + name: 'Curaçao', + capital: 'Willemstad', + languages: ['Dutch', '(Eastern) Punjabi', 'English'], + population: 154843, + flag: 'https://restcountries.eu/data/cuw.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Cyprus', + capital: 'Nicosia', + languages: ['Greek (modern)', 'Turkish', 'Armenian'], + population: 847000, + flag: 'https://restcountries.eu/data/cyp.svg', + currency: 'Euro' + }, + { + name: 'Czech Republic', + capital: 'Prague', + languages: ['Czech', 'Slovak'], + population: 10558524, + flag: 'https://restcountries.eu/data/cze.svg', + currency: 'Czech koruna' + }, + { + name: 'Denmark', + capital: 'Copenhagen', + languages: ['Danish'], + population: 5717014, + flag: 'https://restcountries.eu/data/dnk.svg', + currency: 'Danish krone' + }, + { + name: 'Djibouti', + capital: 'Djibouti', + languages: ['French', 'Arabic'], + population: 900000, + flag: 'https://restcountries.eu/data/dji.svg', + currency: 'Djiboutian franc' + }, + { + name: 'Dominica', + capital: 'Roseau', + languages: ['English'], + population: 71293, + flag: 'https://restcountries.eu/data/dma.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Dominican Republic', + capital: 'Santo Domingo', + languages: ['Spanish'], + population: 10075045, + flag: 'https://restcountries.eu/data/dom.svg', + currency: 'Dominican peso' + }, + { + name: 'Ecuador', + capital: 'Quito', + languages: ['Spanish'], + population: 16545799, + flag: 'https://restcountries.eu/data/ecu.svg', + currency: 'United States dollar' + }, + { + name: 'Egypt', + capital: 'Cairo', + languages: ['Arabic'], + population: 91290000, + flag: 'https://restcountries.eu/data/egy.svg', + currency: 'Egyptian pound' + }, + { + name: 'El Salvador', + capital: 'San Salvador', + languages: ['Spanish'], + population: 6520675, + flag: 'https://restcountries.eu/data/slv.svg', + currency: 'United States dollar' + }, + { + name: 'Equatorial Guinea', + capital: 'Malabo', + languages: ['Spanish', 'French'], + population: 1222442, + flag: 'https://restcountries.eu/data/gnq.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Eritrea', + capital: 'Asmara', + languages: ['Tigrinya', 'Arabic', 'English'], + population: 5352000, + flag: 'https://restcountries.eu/data/eri.svg', + currency: 'Eritrean nakfa' + }, + { + name: 'Estonia', + capital: 'Tallinn', + languages: ['Estonian'], + population: 1315944, + flag: 'https://restcountries.eu/data/est.svg', + currency: 'Euro' + }, + { + name: 'Ethiopia', + capital: 'Addis Ababa', + languages: ['Amharic'], + population: 92206005, + flag: 'https://restcountries.eu/data/eth.svg', + currency: 'Ethiopian birr' + }, + { + name: 'Falkland Islands (Malvinas)', + capital: 'Stanley', + languages: ['English'], + population: 2563, + flag: 'https://restcountries.eu/data/flk.svg', + currency: 'Falkland Islands pound' + }, + { + name: 'Faroe Islands', + capital: 'Tórshavn', + languages: ['Faroese'], + population: 49376, + flag: 'https://restcountries.eu/data/fro.svg', + currency: 'Danish krone' + }, + { + name: 'Fiji', + capital: 'Suva', + languages: ['English', 'Fijian', 'Hindi', 'Urdu'], + population: 867000, + flag: 'https://restcountries.eu/data/fji.svg', + currency: 'Fijian dollar' + }, + { + name: 'Finland', + capital: 'Helsinki', + languages: ['Finnish', 'Swedish'], + population: 5491817, + flag: 'https://restcountries.eu/data/fin.svg', + currency: 'Euro' + }, + { + name: 'France', + capital: 'Paris', + languages: ['French'], + population: 66710000, + flag: 'https://restcountries.eu/data/fra.svg', + currency: 'Euro' + }, + { + name: 'French Guiana', + capital: 'Cayenne', + languages: ['French'], + population: 254541, + flag: 'https://restcountries.eu/data/guf.svg', + currency: 'Euro' + }, + { + name: 'French Polynesia', + capital: 'Papeetē', + languages: ['French'], + population: 271800, + flag: 'https://restcountries.eu/data/pyf.svg', + currency: 'CFP franc' + }, + { + name: 'French Southern Territories', + capital: 'Port-aux-Français', + languages: ['French'], + population: 140, + flag: 'https://restcountries.eu/data/atf.svg', + currency: 'Euro' + }, + { + name: 'Gabon', + capital: 'Libreville', + languages: ['French'], + population: 1802278, + flag: 'https://restcountries.eu/data/gab.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Gambia', + capital: 'Banjul', + languages: ['English'], + population: 1882450, + flag: 'https://restcountries.eu/data/gmb.svg', + currency: 'Gambian dalasi' + }, + { + name: 'Georgia', + capital: 'Tbilisi', + languages: ['Georgian'], + population: 3720400, + flag: 'https://restcountries.eu/data/geo.svg', + currency: 'Georgian Lari' + }, + { + name: 'Germany', + capital: 'Berlin', + languages: ['German'], + population: 81770900, + flag: 'https://restcountries.eu/data/deu.svg', + currency: 'Euro' + }, + { + name: 'Ghana', + capital: 'Accra', + languages: ['English'], + population: 27670174, + flag: 'https://restcountries.eu/data/gha.svg', + currency: 'Ghanaian cedi' + }, + { + name: 'Gibraltar', + capital: 'Gibraltar', + languages: ['English'], + population: 33140, + flag: 'https://restcountries.eu/data/gib.svg', + currency: 'Gibraltar pound' + }, + { + name: 'Greece', + capital: 'Athens', + languages: ['Greek (modern)'], + population: 10858018, + flag: 'https://restcountries.eu/data/grc.svg', + currency: 'Euro' + }, + { + name: 'Greenland', + capital: 'Nuuk', + languages: ['Kalaallisut'], + population: 55847, + flag: 'https://restcountries.eu/data/grl.svg', + currency: 'Danish krone' + }, + { + name: 'Grenada', + capital: "St. George's", + languages: ['English'], + population: 103328, + flag: 'https://restcountries.eu/data/grd.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Guadeloupe', + capital: 'Basse-Terre', + languages: ['French'], + population: 400132, + flag: 'https://restcountries.eu/data/glp.svg', + currency: 'Euro' + }, + { + name: 'Guam', + capital: 'Hagåtña', + languages: ['English', 'Chamorro', 'Spanish'], + population: 184200, + flag: 'https://restcountries.eu/data/gum.svg', + currency: 'United States dollar' + }, + { + name: 'Guatemala', + capital: 'Guatemala City', + languages: ['Spanish'], + population: 16176133, + flag: 'https://restcountries.eu/data/gtm.svg', + currency: 'Guatemalan quetzal' + }, + { + name: 'Guernsey', + capital: 'St. Peter Port', + languages: ['English', 'French'], + population: 62999, + flag: 'https://restcountries.eu/data/ggy.svg', + currency: 'British pound' + }, + { + name: 'Guinea', + capital: 'Conakry', + languages: ['French', 'Fula'], + population: 12947000, + flag: 'https://restcountries.eu/data/gin.svg', + currency: 'Guinean franc' + }, + { + name: 'Guinea-Bissau', + capital: 'Bissau', + languages: ['Portuguese'], + population: 1547777, + flag: 'https://restcountries.eu/data/gnb.svg', + currency: 'West African CFA franc' + }, + { + name: 'Guyana', + capital: 'Georgetown', + languages: ['English'], + population: 746900, + flag: 'https://restcountries.eu/data/guy.svg', + currency: 'Guyanese dollar' + }, + { + name: 'Haiti', + capital: 'Port-au-Prince', + languages: ['French', 'Haitian'], + population: 11078033, + flag: 'https://restcountries.eu/data/hti.svg', + currency: 'Haitian gourde' + }, + { + name: 'Heard Island and McDonald Islands', + capital: '', + languages: ['English'], + population: 0, + flag: 'https://restcountries.eu/data/hmd.svg', + currency: 'Australian dollar' + }, + { + name: 'Holy See', + capital: 'Rome', + languages: ['Latin', 'Italian', 'French', 'German'], + population: 451, + flag: 'https://restcountries.eu/data/vat.svg', + currency: 'Euro' + }, + { + name: 'Honduras', + capital: 'Tegucigalpa', + languages: ['Spanish'], + population: 8576532, + flag: 'https://restcountries.eu/data/hnd.svg', + currency: 'Honduran lempira' + }, + { + name: 'Hong Kong', + capital: 'City of Victoria', + languages: ['English', 'Chinese'], + population: 7324300, + flag: 'https://restcountries.eu/data/hkg.svg', + currency: 'Hong Kong dollar' + }, + { + name: 'Hungary', + capital: 'Budapest', + languages: ['Hungarian'], + population: 9823000, + flag: 'https://restcountries.eu/data/hun.svg', + currency: 'Hungarian forint' + }, + { + name: 'Iceland', + capital: 'Reykjavík', + languages: ['Icelandic'], + population: 334300, + flag: 'https://restcountries.eu/data/isl.svg', + currency: 'Icelandic króna' + }, + { + name: 'India', + capital: 'New Delhi', + languages: ['Hindi', 'English'], + population: 1295210000, + flag: 'https://restcountries.eu/data/ind.svg', + currency: 'Indian rupee' + }, + { + name: 'Indonesia', + capital: 'Jakarta', + languages: ['Indonesian'], + population: 258705000, + flag: 'https://restcountries.eu/data/idn.svg', + currency: 'Indonesian rupiah' + }, + { + name: "Côte d'Ivoire", + capital: 'Yamoussoukro', + languages: ['French'], + population: 22671331, + flag: 'https://restcountries.eu/data/civ.svg', + currency: 'West African CFA franc' + }, + { + name: 'Iran (Islamic Republic of)', + capital: 'Tehran', + languages: ['Persian (Farsi)'], + population: 79369900, + flag: 'https://restcountries.eu/data/irn.svg', + currency: 'Iranian rial' + }, + { + name: 'Iraq', + capital: 'Baghdad', + languages: ['Arabic', 'Kurdish'], + population: 37883543, + flag: 'https://restcountries.eu/data/irq.svg', + currency: 'Iraqi dinar' + }, + { + name: 'Ireland', + capital: 'Dublin', + languages: ['Irish', 'English'], + population: 6378000, + flag: 'https://restcountries.eu/data/irl.svg', + currency: 'Euro' + }, + { + name: 'Isle of Man', + capital: 'Douglas', + languages: ['English', 'Manx'], + population: 84497, + flag: 'https://restcountries.eu/data/imn.svg', + currency: 'British pound' + }, + { + name: 'Israel', + capital: 'Jerusalem', + languages: ['Hebrew (modern)', 'Arabic'], + population: 8527400, + flag: 'https://restcountries.eu/data/isr.svg', + currency: 'Israeli new shekel' + }, + { + name: 'Italy', + capital: 'Rome', + languages: ['Italian'], + population: 60665551, + flag: 'https://restcountries.eu/data/ita.svg', + currency: 'Euro' + }, + { + name: 'Jamaica', + capital: 'Kingston', + languages: ['English'], + population: 2723246, + flag: 'https://restcountries.eu/data/jam.svg', + currency: 'Jamaican dollar' + }, + { + name: 'Japan', + capital: 'Tokyo', + languages: ['Japanese'], + population: 126960000, + flag: 'https://restcountries.eu/data/jpn.svg', + currency: 'Japanese yen' + }, + { + name: 'Jersey', + capital: 'Saint Helier', + languages: ['English', 'French'], + population: 100800, + flag: 'https://restcountries.eu/data/jey.svg', + currency: 'British pound' + }, + { + name: 'Jordan', + capital: 'Amman', + languages: ['Arabic'], + population: 9531712, + flag: 'https://restcountries.eu/data/jor.svg', + currency: 'Jordanian dinar' + }, + { + name: 'Kazakhstan', + capital: 'Astana', + languages: ['Kazakh', 'Russian'], + population: 17753200, + flag: 'https://restcountries.eu/data/kaz.svg', + currency: 'Kazakhstani tenge' + }, + { + name: 'Kenya', + capital: 'Nairobi', + languages: ['English', 'Swahili'], + population: 47251000, + flag: 'https://restcountries.eu/data/ken.svg', + currency: 'Kenyan shilling' + }, + { + name: 'Kiribati', + capital: 'South Tarawa', + languages: ['English'], + population: 113400, + flag: 'https://restcountries.eu/data/kir.svg', + currency: 'Australian dollar' + }, + { + name: 'Kuwait', + capital: 'Kuwait City', + languages: ['Arabic'], + population: 4183658, + flag: 'https://restcountries.eu/data/kwt.svg', + currency: 'Kuwaiti dinar' + }, + { + name: 'Kyrgyzstan', + capital: 'Bishkek', + languages: ['Kyrgyz', 'Russian'], + population: 6047800, + flag: 'https://restcountries.eu/data/kgz.svg', + currency: 'Kyrgyzstani som' + }, + { + name: "Lao People's Democratic Republic", + capital: 'Vientiane', + languages: ['Lao'], + population: 6492400, + flag: 'https://restcountries.eu/data/lao.svg', + currency: 'Lao kip' + }, + { + name: 'Latvia', + capital: 'Riga', + languages: ['Latvian'], + population: 1961600, + flag: 'https://restcountries.eu/data/lva.svg', + currency: 'Euro' + }, + { + name: 'Lebanon', + capital: 'Beirut', + languages: ['Arabic', 'French'], + population: 5988000, + flag: 'https://restcountries.eu/data/lbn.svg', + currency: 'Lebanese pound' + }, + { + name: 'Lesotho', + capital: 'Maseru', + languages: ['English', 'Southern Sotho'], + population: 1894194, + flag: 'https://restcountries.eu/data/lso.svg', + currency: 'Lesotho loti' + }, + { + name: 'Liberia', + capital: 'Monrovia', + languages: ['English'], + population: 4615000, + flag: 'https://restcountries.eu/data/lbr.svg', + currency: 'Liberian dollar' + }, + { + name: 'Libya', + capital: 'Tripoli', + languages: ['Arabic'], + population: 6385000, + flag: 'https://restcountries.eu/data/lby.svg', + currency: 'Libyan dinar' + }, + { + name: 'Liechtenstein', + capital: 'Vaduz', + languages: ['German'], + population: 37623, + flag: 'https://restcountries.eu/data/lie.svg', + currency: 'Swiss franc' + }, + { + name: 'Lithuania', + capital: 'Vilnius', + languages: ['Lithuanian'], + population: 2872294, + flag: 'https://restcountries.eu/data/ltu.svg', + currency: 'Euro' + }, + { + name: 'Luxembourg', + capital: 'Luxembourg', + languages: ['French', 'German', 'Luxembourgish'], + population: 576200, + flag: 'https://restcountries.eu/data/lux.svg', + currency: 'Euro' + }, + { + name: 'Macao', + capital: '', + languages: ['Chinese', 'Portuguese'], + population: 649100, + flag: 'https://restcountries.eu/data/mac.svg', + currency: 'Macanese pataca' + }, + { + name: 'Macedonia (the former Yugoslav Republic of)', + capital: 'Skopje', + languages: ['Macedonian'], + population: 2058539, + flag: 'https://restcountries.eu/data/mkd.svg', + currency: 'Macedonian denar' + }, + { + name: 'Madagascar', + capital: 'Antananarivo', + languages: ['French', 'Malagasy'], + population: 22434363, + flag: 'https://restcountries.eu/data/mdg.svg', + currency: 'Malagasy ariary' + }, + { + name: 'Malawi', + capital: 'Lilongwe', + languages: ['English', 'Chichewa'], + population: 16832910, + flag: 'https://restcountries.eu/data/mwi.svg', + currency: 'Malawian kwacha' + }, + { + name: 'Malaysia', + capital: 'Kuala Lumpur', + languages: ['Malaysian'], + population: 31405416, + flag: 'https://restcountries.eu/data/mys.svg', + currency: 'Malaysian ringgit' + }, + { + name: 'Maldives', + capital: 'Malé', + languages: ['Divehi'], + population: 344023, + flag: 'https://restcountries.eu/data/mdv.svg', + currency: 'Maldivian rufiyaa' + }, + { + name: 'Mali', + capital: 'Bamako', + languages: ['French'], + population: 18135000, + flag: 'https://restcountries.eu/data/mli.svg', + currency: 'West African CFA franc' + }, + { + name: 'Malta', + capital: 'Valletta', + languages: ['Maltese', 'English'], + population: 425384, + flag: 'https://restcountries.eu/data/mlt.svg', + currency: 'Euro' + }, + { + name: 'Marshall Islands', + capital: 'Majuro', + languages: ['English', 'Marshallese'], + population: 54880, + flag: 'https://restcountries.eu/data/mhl.svg', + currency: 'United States dollar' + }, + { + name: 'Martinique', + capital: 'Fort-de-France', + languages: ['French'], + population: 378243, + flag: 'https://restcountries.eu/data/mtq.svg', + currency: 'Euro' + }, + { + name: 'Mauritania', + capital: 'Nouakchott', + languages: ['Arabic'], + population: 3718678, + flag: 'https://restcountries.eu/data/mrt.svg', + currency: 'Mauritanian ouguiya' + }, + { + name: 'Mauritius', + capital: 'Port Louis', + languages: ['English'], + population: 1262879, + flag: 'https://restcountries.eu/data/mus.svg', + currency: 'Mauritian rupee' + }, + { + name: 'Mayotte', + capital: 'Mamoudzou', + languages: ['French'], + population: 226915, + flag: 'https://restcountries.eu/data/myt.svg', + currency: 'Euro' + }, + { + name: 'Mexico', + capital: 'Mexico City', + languages: ['Spanish'], + population: 122273473, + flag: 'https://restcountries.eu/data/mex.svg', + currency: 'Mexican peso' + }, + { + name: 'Micronesia (Federated States of)', + capital: 'Palikir', + languages: ['English'], + population: 102800, + flag: 'https://restcountries.eu/data/fsm.svg', + currency: '[D]' + }, + { + name: 'Moldova (Republic of)', + capital: 'Chișinău', + languages: ['Romanian'], + population: 3553100, + flag: 'https://restcountries.eu/data/mda.svg', + currency: 'Moldovan leu' + }, + { + name: 'Monaco', + capital: 'Monaco', + languages: ['French'], + population: 38400, + flag: 'https://restcountries.eu/data/mco.svg', + currency: 'Euro' + }, + { + name: 'Mongolia', + capital: 'Ulan Bator', + languages: ['Mongolian'], + population: 3093100, + flag: 'https://restcountries.eu/data/mng.svg', + currency: 'Mongolian tögrög' + }, + { + name: 'Montenegro', + capital: 'Podgorica', + languages: ['Serbian', 'Bosnian', 'Albanian', 'Croatian'], + population: 621810, + flag: 'https://restcountries.eu/data/mne.svg', + currency: 'Euro' + }, + { + name: 'Montserrat', + capital: 'Plymouth', + languages: ['English'], + population: 4922, + flag: 'https://restcountries.eu/data/msr.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Morocco', + capital: 'Rabat', + languages: ['Arabic'], + population: 33337529, + flag: 'https://restcountries.eu/data/mar.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Mozambique', + capital: 'Maputo', + languages: ['Portuguese'], + population: 26423700, + flag: 'https://restcountries.eu/data/moz.svg', + currency: 'Mozambican metical' + }, + { + name: 'Myanmar', + capital: 'Naypyidaw', + languages: ['Burmese'], + population: 51419420, + flag: 'https://restcountries.eu/data/mmr.svg', + currency: 'Burmese kyat' + }, + { + name: 'Namibia', + capital: 'Windhoek', + languages: ['English', 'Afrikaans'], + population: 2324388, + flag: 'https://restcountries.eu/data/nam.svg', + currency: 'Namibian dollar' + }, + { + name: 'Nauru', + capital: 'Yaren', + languages: ['English', 'Nauruan'], + population: 10084, + flag: 'https://restcountries.eu/data/nru.svg', + currency: 'Australian dollar' + }, + { + name: 'Nepal', + capital: 'Kathmandu', + languages: ['Nepali'], + population: 28431500, + flag: 'https://restcountries.eu/data/npl.svg', + currency: 'Nepalese rupee' + }, + { + name: 'Netherlands', + capital: 'Amsterdam', + languages: ['Dutch'], + population: 17019800, + flag: 'https://restcountries.eu/data/nld.svg', + currency: 'Euro' + }, + { + name: 'New Caledonia', + capital: 'Nouméa', + languages: ['French'], + population: 268767, + flag: 'https://restcountries.eu/data/ncl.svg', + currency: 'CFP franc' + }, + { + name: 'New Zealand', + capital: 'Wellington', + languages: ['English', 'Māori'], + population: 4697854, + flag: 'https://restcountries.eu/data/nzl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Nicaragua', + capital: 'Managua', + languages: ['Spanish'], + population: 6262703, + flag: 'https://restcountries.eu/data/nic.svg', + currency: 'Nicaraguan córdoba' + }, + { + name: 'Niger', + capital: 'Niamey', + languages: ['French'], + population: 20715000, + flag: 'https://restcountries.eu/data/ner.svg', + currency: 'West African CFA franc' + }, + { + name: 'Nigeria', + capital: 'Abuja', + languages: ['English'], + population: 186988000, + flag: 'https://restcountries.eu/data/nga.svg', + currency: 'Nigerian naira' + }, + { + name: 'Niue', + capital: 'Alofi', + languages: ['English'], + population: 1470, + flag: 'https://restcountries.eu/data/niu.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Norfolk Island', + capital: 'Kingston', + languages: ['English'], + population: 2302, + flag: 'https://restcountries.eu/data/nfk.svg', + currency: 'Australian dollar' + }, + { + name: "Korea (Democratic People's Republic of)", + capital: 'Pyongyang', + languages: ['Korean'], + population: 25281000, + flag: 'https://restcountries.eu/data/prk.svg', + currency: 'North Korean won' + }, + { + name: 'Northern Mariana Islands', + capital: 'Saipan', + languages: ['English', 'Chamorro'], + population: 56940, + flag: 'https://restcountries.eu/data/mnp.svg', + currency: 'United States dollar' + }, + { + name: 'Norway', + capital: 'Oslo', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 5223256, + flag: 'https://restcountries.eu/data/nor.svg', + currency: 'Norwegian krone' + }, + { + name: 'Oman', + capital: 'Muscat', + languages: ['Arabic'], + population: 4420133, + flag: 'https://restcountries.eu/data/omn.svg', + currency: 'Omani rial' + }, + { + name: 'Pakistan', + capital: 'Islamabad', + languages: ['English', 'Urdu'], + population: 194125062, + flag: 'https://restcountries.eu/data/pak.svg', + currency: 'Pakistani rupee' + }, + { + name: 'Palau', + capital: 'Ngerulmud', + languages: ['English'], + population: 17950, + flag: 'https://restcountries.eu/data/plw.svg', + currency: '[E]' + }, + { + name: 'Palestine, State of', + capital: 'Ramallah', + languages: ['Arabic'], + population: 4682467, + flag: 'https://restcountries.eu/data/pse.svg', + currency: 'Israeli new sheqel' + }, + { + name: 'Panama', + capital: 'Panama City', + languages: ['Spanish'], + population: 3814672, + flag: 'https://restcountries.eu/data/pan.svg', + currency: 'Panamanian balboa' + }, + { + name: 'Papua New Guinea', + capital: 'Port Moresby', + languages: ['English'], + population: 8083700, + flag: 'https://restcountries.eu/data/png.svg', + currency: 'Papua New Guinean kina' + }, + { + name: 'Paraguay', + capital: 'Asunción', + languages: ['Spanish', 'Guaraní'], + population: 6854536, + flag: 'https://restcountries.eu/data/pry.svg', + currency: 'Paraguayan guaraní' + }, + { + name: 'Peru', + capital: 'Lima', + languages: ['Spanish'], + population: 31488700, + flag: 'https://restcountries.eu/data/per.svg', + currency: 'Peruvian sol' + }, + { + name: 'Philippines', + capital: 'Manila', + languages: ['English'], + population: 103279800, + flag: 'https://restcountries.eu/data/phl.svg', + currency: 'Philippine peso' + }, + { + name: 'Pitcairn', + capital: 'Adamstown', + languages: ['English'], + population: 56, + flag: 'https://restcountries.eu/data/pcn.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Poland', + capital: 'Warsaw', + languages: ['Polish'], + population: 38437239, + flag: 'https://restcountries.eu/data/pol.svg', + currency: 'Polish złoty' + }, + { + name: 'Portugal', + capital: 'Lisbon', + languages: ['Portuguese'], + population: 10374822, + flag: 'https://restcountries.eu/data/prt.svg', + currency: 'Euro' + }, + { + name: 'Puerto Rico', + capital: 'San Juan', + languages: ['Spanish', 'English'], + population: 3474182, + flag: 'https://restcountries.eu/data/pri.svg', + currency: 'United States dollar' + }, + { + name: 'Qatar', + capital: 'Doha', + languages: ['Arabic'], + population: 2587564, + flag: 'https://restcountries.eu/data/qat.svg', + currency: 'Qatari riyal' + }, + { + name: 'Republic of Kosovo', + capital: 'Pristina', + languages: ['Albanian', 'Serbian'], + population: 1733842, + flag: 'https://restcountries.eu/data/kos.svg', + currency: 'Euro' + }, + { + name: 'Réunion', + capital: 'Saint-Denis', + languages: ['French'], + population: 840974, + flag: 'https://restcountries.eu/data/reu.svg', + currency: 'Euro' + }, + { + name: 'Romania', + capital: 'Bucharest', + languages: ['Romanian'], + population: 19861408, + flag: 'https://restcountries.eu/data/rou.svg', + currency: 'Romanian leu' + }, + { + name: 'Russian Federation', + capital: 'Moscow', + languages: ['Russian'], + population: 146599183, + flag: 'https://restcountries.eu/data/rus.svg', + currency: 'Russian ruble' + }, + { + name: 'Rwanda', + capital: 'Kigali', + languages: ['Kinyarwanda', 'English', 'French'], + population: 11553188, + flag: 'https://restcountries.eu/data/rwa.svg', + currency: 'Rwandan franc' + }, + { + name: 'Saint Barthélemy', + capital: 'Gustavia', + languages: ['French'], + population: 9417, + flag: 'https://restcountries.eu/data/blm.svg', + currency: 'Euro' + }, + { + name: 'Saint Helena, Ascension and Tristan da Cunha', + capital: 'Jamestown', + languages: ['English'], + population: 4255, + flag: 'https://restcountries.eu/data/shn.svg', + currency: 'Saint Helena pound' + }, + { + name: 'Saint Kitts and Nevis', + capital: 'Basseterre', + languages: ['English'], + population: 46204, + flag: 'https://restcountries.eu/data/kna.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Lucia', + capital: 'Castries', + languages: ['English'], + population: 186000, + flag: 'https://restcountries.eu/data/lca.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Martin (French part)', + capital: 'Marigot', + languages: ['English', 'French', 'Dutch'], + population: 36979, + flag: 'https://restcountries.eu/data/maf.svg', + currency: 'Euro' + }, + { + name: 'Saint Pierre and Miquelon', + capital: 'Saint-Pierre', + languages: ['French'], + population: 6069, + flag: 'https://restcountries.eu/data/spm.svg', + currency: 'Euro' + }, + { + name: 'Saint Vincent and the Grenadines', + capital: 'Kingstown', + languages: ['English'], + population: 109991, + flag: 'https://restcountries.eu/data/vct.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Samoa', + capital: 'Apia', + languages: ['Samoan', 'English'], + population: 194899, + flag: 'https://restcountries.eu/data/wsm.svg', + currency: 'Samoan tālā' + }, + { + name: 'San Marino', + capital: 'City of San Marino', + languages: ['Italian'], + population: 33005, + flag: 'https://restcountries.eu/data/smr.svg', + currency: 'Euro' + }, + { + name: 'Sao Tome and Principe', + capital: 'São Tomé', + languages: ['Portuguese'], + population: 187356, + flag: 'https://restcountries.eu/data/stp.svg', + currency: 'São Tomé and Príncipe dobra' + }, + { + name: 'Saudi Arabia', + capital: 'Riyadh', + languages: ['Arabic'], + population: 32248200, + flag: 'https://restcountries.eu/data/sau.svg', + currency: 'Saudi riyal' + }, + { + name: 'Senegal', + capital: 'Dakar', + languages: ['French'], + population: 14799859, + flag: 'https://restcountries.eu/data/sen.svg', + currency: 'West African CFA franc' + }, + { + name: 'Serbia', + capital: 'Belgrade', + languages: ['Serbian'], + population: 7076372, + flag: 'https://restcountries.eu/data/srb.svg', + currency: 'Serbian dinar' + }, + { + name: 'Seychelles', + capital: 'Victoria', + languages: ['French', 'English'], + population: 91400, + flag: 'https://restcountries.eu/data/syc.svg', + currency: 'Seychellois rupee' + }, + { + name: 'Sierra Leone', + capital: 'Freetown', + languages: ['English'], + population: 7075641, + flag: 'https://restcountries.eu/data/sle.svg', + currency: 'Sierra Leonean leone' + }, + { + name: 'Singapore', + capital: 'Singapore', + languages: ['English', 'Malay', 'Tamil', 'Chinese'], + population: 5535000, + flag: 'https://restcountries.eu/data/sgp.svg', + currency: 'Brunei dollar' + }, + { + name: 'Sint Maarten (Dutch part)', + capital: 'Philipsburg', + languages: ['Dutch', 'English'], + population: 38247, + flag: 'https://restcountries.eu/data/sxm.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Slovakia', + capital: 'Bratislava', + languages: ['Slovak'], + population: 5426252, + flag: 'https://restcountries.eu/data/svk.svg', + currency: 'Euro' + }, + { + name: 'Slovenia', + capital: 'Ljubljana', + languages: ['Slovene'], + population: 2064188, + flag: 'https://restcountries.eu/data/svn.svg', + currency: 'Euro' + }, + { + name: 'Solomon Islands', + capital: 'Honiara', + languages: ['English'], + population: 642000, + flag: 'https://restcountries.eu/data/slb.svg', + currency: 'Solomon Islands dollar' + }, + { + name: 'Somalia', + capital: 'Mogadishu', + languages: ['Somali', 'Arabic'], + population: 11079000, + flag: 'https://restcountries.eu/data/som.svg', + currency: 'Somali shilling' + }, + { + name: 'South Africa', + capital: 'Pretoria', + languages: [ + 'Afrikaans', + 'English', + 'Southern Ndebele', + 'Southern Sotho', + 'Swati', + 'Tswana', + 'Tsonga', + 'Venda', + 'Xhosa', + 'Zulu' + ], + population: 55653654, + flag: 'https://restcountries.eu/data/zaf.svg', + currency: 'South African rand' + }, + { + name: 'South Georgia and the South Sandwich Islands', + capital: 'King Edward Point', + languages: ['English'], + population: 30, + flag: 'https://restcountries.eu/data/sgs.svg', + currency: 'British pound' + }, + { + name: 'Korea (Republic of)', + capital: 'Seoul', + languages: ['Korean'], + population: 50801405, + flag: 'https://restcountries.eu/data/kor.svg', + currency: 'South Korean won' + }, + { + name: 'South Sudan', + capital: 'Juba', + languages: ['English'], + population: 12131000, + flag: 'https://restcountries.eu/data/ssd.svg', + currency: 'South Sudanese pound' + }, + { + name: 'Spain', + capital: 'Madrid', + languages: ['Spanish'], + population: 46438422, + flag: 'https://restcountries.eu/data/esp.svg', + currency: 'Euro' + }, + { + name: 'Sri Lanka', + capital: 'Colombo', + languages: ['Sinhalese', 'Tamil'], + population: 20966000, + flag: 'https://restcountries.eu/data/lka.svg', + currency: 'Sri Lankan rupee' + }, + { + name: 'Sudan', + capital: 'Khartoum', + languages: ['Arabic', 'English'], + population: 39598700, + flag: 'https://restcountries.eu/data/sdn.svg', + currency: 'Sudanese pound' + }, + { + name: 'Suriname', + capital: 'Paramaribo', + languages: ['Dutch'], + population: 541638, + flag: 'https://restcountries.eu/data/sur.svg', + currency: 'Surinamese dollar' + }, + { + name: 'Svalbard and Jan Mayen', + capital: 'Longyearbyen', + languages: ['Norwegian'], + population: 2562, + flag: 'https://restcountries.eu/data/sjm.svg', + currency: 'Norwegian krone' + }, + { + name: 'Swaziland', + capital: 'Lobamba', + languages: ['English', 'Swati'], + population: 1132657, + flag: 'https://restcountries.eu/data/swz.svg', + currency: 'Swazi lilangeni' + }, + { + name: 'Sweden', + capital: 'Stockholm', + languages: ['Swedish'], + population: 9894888, + flag: 'https://restcountries.eu/data/swe.svg', + currency: 'Swedish krona' + }, + { + name: 'Switzerland', + capital: 'Bern', + languages: ['German', 'French', 'Italian'], + population: 8341600, + flag: 'https://restcountries.eu/data/che.svg', + currency: 'Swiss franc' + }, + { + name: 'Syrian Arab Republic', + capital: 'Damascus', + languages: ['Arabic'], + population: 18564000, + flag: 'https://restcountries.eu/data/syr.svg', + currency: 'Syrian pound' + }, + { + name: 'Taiwan', + capital: 'Taipei', + languages: ['Chinese'], + population: 23503349, + flag: 'https://restcountries.eu/data/twn.svg', + currency: 'New Taiwan dollar' + }, + { + name: 'Tajikistan', + capital: 'Dushanbe', + languages: ['Tajik', 'Russian'], + population: 8593600, + flag: 'https://restcountries.eu/data/tjk.svg', + currency: 'Tajikistani somoni' + }, + { + name: 'Tanzania, United Republic of', + capital: 'Dodoma', + languages: ['Swahili', 'English'], + population: 55155000, + flag: 'https://restcountries.eu/data/tza.svg', + currency: 'Tanzanian shilling' + }, + { + name: 'Thailand', + capital: 'Bangkok', + languages: ['Thai'], + population: 65327652, + flag: 'https://restcountries.eu/data/tha.svg', + currency: 'Thai baht' + }, + { + name: 'Timor-Leste', + capital: 'Dili', + languages: ['Portuguese'], + population: 1167242, + flag: 'https://restcountries.eu/data/tls.svg', + currency: 'United States dollar' + }, + { + name: 'Togo', + capital: 'Lomé', + languages: ['French'], + population: 7143000, + flag: 'https://restcountries.eu/data/tgo.svg', + currency: 'West African CFA franc' + }, + { + name: 'Tokelau', + capital: 'Fakaofo', + languages: ['English'], + population: 1411, + flag: 'https://restcountries.eu/data/tkl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Tonga', + capital: "Nuku'alofa", + languages: ['English', 'Tonga (Tonga Islands)'], + population: 103252, + flag: 'https://restcountries.eu/data/ton.svg', + currency: 'Tongan paʻanga' + }, + { + name: 'Trinidad and Tobago', + capital: 'Port of Spain', + languages: ['English'], + population: 1349667, + flag: 'https://restcountries.eu/data/tto.svg', + currency: 'Trinidad and Tobago dollar' + }, + { + name: 'Tunisia', + capital: 'Tunis', + languages: ['Arabic'], + population: 11154400, + flag: 'https://restcountries.eu/data/tun.svg', + currency: 'Tunisian dinar' + }, + { + name: 'Turkey', + capital: 'Ankara', + languages: ['Turkish'], + population: 78741053, + flag: 'https://restcountries.eu/data/tur.svg', + currency: 'Turkish lira' + }, + { + name: 'Turkmenistan', + capital: 'Ashgabat', + languages: ['Turkmen', 'Russian'], + population: 4751120, + flag: 'https://restcountries.eu/data/tkm.svg', + currency: 'Turkmenistan manat' + }, + { + name: 'Turks and Caicos Islands', + capital: 'Cockburn Town', + languages: ['English'], + population: 31458, + flag: 'https://restcountries.eu/data/tca.svg', + currency: 'United States dollar' + }, + { + name: 'Tuvalu', + capital: 'Funafuti', + languages: ['English'], + population: 10640, + flag: 'https://restcountries.eu/data/tuv.svg', + currency: 'Australian dollar' + }, + { + name: 'Uganda', + capital: 'Kampala', + languages: ['English', 'Swahili'], + population: 33860700, + flag: 'https://restcountries.eu/data/uga.svg', + currency: 'Ugandan shilling' + }, + { + name: 'Ukraine', + capital: 'Kiev', + languages: ['Ukrainian'], + population: 42692393, + flag: 'https://restcountries.eu/data/ukr.svg', + currency: 'Ukrainian hryvnia' + }, + { + name: 'United Arab Emirates', + capital: 'Abu Dhabi', + languages: ['Arabic'], + population: 9856000, + flag: 'https://restcountries.eu/data/are.svg', + currency: 'United Arab Emirates dirham' + }, + { + name: 'United Kingdom of Great Britain and Northern Ireland', + capital: 'London', + languages: ['English'], + population: 65110000, + flag: 'https://restcountries.eu/data/gbr.svg', + currency: 'British pound' + }, + { + name: 'United States of America', + capital: 'Washington, D.C.', + languages: ['English'], + population: 323947000, + flag: 'https://restcountries.eu/data/usa.svg', + currency: 'United States dollar' + }, + { + name: 'Uruguay', + capital: 'Montevideo', + languages: ['Spanish'], + population: 3480222, + flag: 'https://restcountries.eu/data/ury.svg', + currency: 'Uruguayan peso' + }, + { + name: 'Uzbekistan', + capital: 'Tashkent', + languages: ['Uzbek', 'Russian'], + population: 31576400, + flag: 'https://restcountries.eu/data/uzb.svg', + currency: "Uzbekistani so'm" + }, + { + name: 'Vanuatu', + capital: 'Port Vila', + languages: ['Bislama', 'English', 'French'], + population: 277500, + flag: 'https://restcountries.eu/data/vut.svg', + currency: 'Vanuatu vatu' + }, + { + name: 'Venezuela (Bolivarian Republic of)', + capital: 'Caracas', + languages: ['Spanish'], + population: 31028700, + flag: 'https://restcountries.eu/data/ven.svg', + currency: 'Venezuelan bolívar' + }, + { + name: 'Viet Nam', + capital: 'Hanoi', + languages: ['Vietnamese'], + population: 92700000, + flag: 'https://restcountries.eu/data/vnm.svg', + currency: 'Vietnamese đồng' + }, + { + name: 'Wallis and Futuna', + capital: 'Mata-Utu', + languages: ['French'], + population: 11750, + flag: 'https://restcountries.eu/data/wlf.svg', + currency: 'CFP franc' + }, + { + name: 'Western Sahara', + capital: 'El Aaiún', + languages: ['Spanish'], + population: 510713, + flag: 'https://restcountries.eu/data/esh.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Yemen', + capital: "Sana'a", + languages: ['Arabic'], + population: 27478000, + flag: 'https://restcountries.eu/data/yem.svg', + currency: 'Yemeni rial' + }, + { + name: 'Zambia', + capital: 'Lusaka', + languages: ['English'], + population: 15933883, + flag: 'https://restcountries.eu/data/zmb.svg', + currency: 'Zambian kwacha' + }, + { + name: 'Zimbabwe', + capital: 'Harare', + languages: ['English', 'Shona', 'Northern Ndebele'], + population: 14240168, + flag: 'https://restcountries.eu/data/zwe.svg', + currency: 'Botswana pula' + } +] diff --git a/23_Day_Event_listeners/23_day_starters/design/dom_min_project_keycode_day_3.2.gif b/23_Day_Event_listeners/23_day_starters/design/dom_min_project_keycode_day_3.2.gif new file mode 100644 index 0000000..7c75c14 Binary files /dev/null and b/23_Day_Event_listeners/23_day_starters/design/dom_min_project_keycode_day_3.2.gif differ diff --git a/23_Day_Event_listeners/23_day_starters/design/dom_min_project_number_generator_day_3.1.gif b/23_Day_Event_listeners/23_day_starters/design/dom_min_project_number_generator_day_3.1.gif new file mode 100644 index 0000000..59a8dd0 Binary files /dev/null and b/23_Day_Event_listeners/23_day_starters/design/dom_min_project_number_generator_day_3.1.gif differ diff --git a/23_Day_Event_listeners/23_day_starters/project_1/index.html b/23_Day_Event_listeners/23_day_starters/project_1/index.html new file mode 100644 index 0000000..f8f52cf --- /dev/null +++ b/23_Day_Event_listeners/23_day_starters/project_1/index.html @@ -0,0 +1,22 @@ + + + + + 30DaysOfJavaScript:23 Day: Number Generator + + + +

    Number Generator

    +

    30DaysOfJavaScript:DOM Day 2

    +

    Author: Asabeneh Yetayeh

    +
    + +
    + + + + + + + + \ No newline at end of file diff --git a/23_Day_Event_listeners/23_day_starters/project_1/scripts/main.js b/23_Day_Event_listeners/23_day_starters/project_1/scripts/main.js new file mode 100644 index 0000000..c6045c8 --- /dev/null +++ b/23_Day_Event_listeners/23_day_starters/project_1/scripts/main.js @@ -0,0 +1,2 @@ +console.log(countries) +alert('Open the console and check if the countries has been loaded') \ No newline at end of file diff --git a/23_Day_Event_listeners/23_day_starters/project_2/index.html b/23_Day_Event_listeners/23_day_starters/project_2/index.html new file mode 100644 index 0000000..666b473 --- /dev/null +++ b/23_Day_Event_listeners/23_day_starters/project_2/index.html @@ -0,0 +1,15 @@ + + + + + 30DaysOfJavaScript:23 Day: Keyboard Key + + + + + + + + + + \ No newline at end of file diff --git a/23_Day_Event_listeners/23_day_starters/project_2/scripts/main.js b/23_Day_Event_listeners/23_day_starters/project_2/scripts/main.js new file mode 100644 index 0000000..c6045c8 --- /dev/null +++ b/23_Day_Event_listeners/23_day_starters/project_2/scripts/main.js @@ -0,0 +1,2 @@ +console.log(countries) +alert('Open the console and check if the countries has been loaded') \ No newline at end of file diff --git a/24_Day_Project_solar_system/24_day_project_solar_system.md b/24_Day_Project_solar_system/24_day_project_solar_system.md new file mode 100644 index 0000000..ecaf0f2 --- /dev/null +++ b/24_Day_Project_solar_system/24_day_project_solar_system.md @@ -0,0 +1,38 @@ +
    +

    30 Days Of JavaScript: Mini Project Solar System

    + + + + + Twitter Follow + + +Author: +Asabeneh Yetayeh
    + January, 2020 +
    + +
    + +[<< Day 23](../23_Day_Event_listeners/23_day_event_listeners.md) | [Day 25 >>](../25_Day_World_countries_data_visualization_1/25_day_world_countries_data_visualization_1.md) + +![Thirty Days Of JavaScript](../images/banners/day_1_24.png) + +- [Day 24](#day-24) + - [Exercises](#exercises) + - [Exercise: Level 1](#exercise-level-1) + +# Day 24 + +## Exercises + +### Exercise: Level 1 + +1. Develop a small application which calculate a weight of an object in a certain planet. The gif image is not complete check the video in the starter file. + +![Solar System](./../images/projects/dom_min_project_solar_system_day_4.1.gif) + +🎉 CONGRATULATIONS ! 🎉 + +[<< Day 23](../23_Day_Event_listeners/23_day_event_listeners.md) | [Day 25 >>](../25_Day_World_countries_data_visualization_1/25_day_world_countries_data_visualization_1.md) + diff --git a/24_Day_Project_solar_system/24_day_starter/design/dom_min_project_solar_system_day_4.1.mp4 b/24_Day_Project_solar_system/24_day_starter/design/dom_min_project_solar_system_day_4.1.mp4 new file mode 100644 index 0000000..69ce936 Binary files /dev/null and b/24_Day_Project_solar_system/24_day_starter/design/dom_min_project_solar_system_day_4.1.mp4 differ diff --git a/24_Day_Project_solar_system/24_day_starter/images/earth.png b/24_Day_Project_solar_system/24_day_starter/images/earth.png new file mode 100644 index 0000000..6b54915 Binary files /dev/null and b/24_Day_Project_solar_system/24_day_starter/images/earth.png differ diff --git a/24_Day_Project_solar_system/24_day_starter/images/galaxy.gif b/24_Day_Project_solar_system/24_day_starter/images/galaxy.gif new file mode 100644 index 0000000..3c8aab6 Binary files /dev/null and b/24_Day_Project_solar_system/24_day_starter/images/galaxy.gif differ diff --git a/24_Day_Project_solar_system/24_day_starter/images/jupiter.png b/24_Day_Project_solar_system/24_day_starter/images/jupiter.png new file mode 100644 index 0000000..63cc77c Binary files /dev/null and b/24_Day_Project_solar_system/24_day_starter/images/jupiter.png differ diff --git a/24_Day_Project_solar_system/24_day_starter/images/mars.png b/24_Day_Project_solar_system/24_day_starter/images/mars.png new file mode 100644 index 0000000..d035d3b Binary files /dev/null and b/24_Day_Project_solar_system/24_day_starter/images/mars.png differ diff --git a/24_Day_Project_solar_system/24_day_starter/images/mercury.png b/24_Day_Project_solar_system/24_day_starter/images/mercury.png new file mode 100644 index 0000000..278acf8 Binary files /dev/null and b/24_Day_Project_solar_system/24_day_starter/images/mercury.png differ diff --git a/24_Day_Project_solar_system/24_day_starter/images/moon.png b/24_Day_Project_solar_system/24_day_starter/images/moon.png new file mode 100644 index 0000000..d256266 Binary files /dev/null and b/24_Day_Project_solar_system/24_day_starter/images/moon.png differ diff --git a/24_Day_Project_solar_system/24_day_starter/images/neptune.png b/24_Day_Project_solar_system/24_day_starter/images/neptune.png new file mode 100644 index 0000000..9d824d2 Binary files /dev/null and b/24_Day_Project_solar_system/24_day_starter/images/neptune.png differ diff --git a/24_Day_Project_solar_system/24_day_starter/images/pluto.png b/24_Day_Project_solar_system/24_day_starter/images/pluto.png new file mode 100644 index 0000000..62beb40 Binary files /dev/null and b/24_Day_Project_solar_system/24_day_starter/images/pluto.png differ diff --git a/24_Day_Project_solar_system/24_day_starter/images/saturn.png b/24_Day_Project_solar_system/24_day_starter/images/saturn.png new file mode 100644 index 0000000..9bd6d92 Binary files /dev/null and b/24_Day_Project_solar_system/24_day_starter/images/saturn.png differ diff --git a/24_Day_Project_solar_system/24_day_starter/images/uranus.png b/24_Day_Project_solar_system/24_day_starter/images/uranus.png new file mode 100644 index 0000000..7e30109 Binary files /dev/null and b/24_Day_Project_solar_system/24_day_starter/images/uranus.png differ diff --git a/24_Day_Project_solar_system/24_day_starter/images/venus.png b/24_Day_Project_solar_system/24_day_starter/images/venus.png new file mode 100644 index 0000000..d865f92 Binary files /dev/null and b/24_Day_Project_solar_system/24_day_starter/images/venus.png differ diff --git a/24_Day_Project_solar_system/24_day_starter/index.html b/24_Day_Project_solar_system/24_day_starter/index.html new file mode 100644 index 0000000..b351e19 --- /dev/null +++ b/24_Day_Project_solar_system/24_day_starter/index.html @@ -0,0 +1,39 @@ + + + + + Solar System: Document Object Model:30 Days Of JavaScript + + + + +
    +

    Calculate a weight of an object on a planet

    + + + + + +
    +
    +
    +
    + +
    +
    + +
    + + +
    + + + + + + + + + \ No newline at end of file diff --git a/24_Day_Project_solar_system/24_day_starter/scripts/main.js b/24_Day_Project_solar_system/24_day_starter/scripts/main.js new file mode 100644 index 0000000..c6045c8 --- /dev/null +++ b/24_Day_Project_solar_system/24_day_starter/scripts/main.js @@ -0,0 +1,2 @@ +console.log(countries) +alert('Open the console and check if the countries has been loaded') \ No newline at end of file diff --git a/25_Day_World_countries_data_visualization_1/25_day_starter/data/countries_data.js b/25_Day_World_countries_data_visualization_1/25_day_starter/data/countries_data.js new file mode 100644 index 0000000..92acddd --- /dev/null +++ b/25_Day_World_countries_data_visualization_1/25_day_starter/data/countries_data.js @@ -0,0 +1,2013 @@ +const countries = [ + { + name: 'Afghanistan', + capital: 'Kabul', + languages: ['Pashto', 'Uzbek', 'Turkmen'], + population: 27657145, + flag: 'https://restcountries.eu/data/afg.svg', + currency: 'Afghan afghani' + }, + { + name: 'Åland Islands', + capital: 'Mariehamn', + languages: ['Swedish'], + population: 28875, + flag: 'https://restcountries.eu/data/ala.svg', + currency: 'Euro' + }, + { + name: 'Albania', + capital: 'Tirana', + languages: ['Albanian'], + population: 2886026, + flag: 'https://restcountries.eu/data/alb.svg', + currency: 'Albanian lek' + }, + { + name: 'Algeria', + capital: 'Algiers', + languages: ['Arabic'], + population: 40400000, + flag: 'https://restcountries.eu/data/dza.svg', + currency: 'Algerian dinar' + }, + { + name: 'American Samoa', + capital: 'Pago Pago', + languages: ['English', 'Samoan'], + population: 57100, + flag: 'https://restcountries.eu/data/asm.svg', + currency: 'United State Dollar' + }, + { + name: 'Andorra', + capital: 'Andorra la Vella', + languages: ['Catalan'], + population: 78014, + flag: 'https://restcountries.eu/data/and.svg', + currency: 'Euro' + }, + { + name: 'Angola', + capital: 'Luanda', + languages: ['Portuguese'], + population: 25868000, + flag: 'https://restcountries.eu/data/ago.svg', + currency: 'Angolan kwanza' + }, + { + name: 'Anguilla', + capital: 'The Valley', + languages: ['English'], + population: 13452, + flag: 'https://restcountries.eu/data/aia.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Antarctica', + capital: '', + languages: ['English', 'Russian'], + population: 1000, + flag: 'https://restcountries.eu/data/ata.svg', + currency: 'Australian dollar' + }, + { + name: 'Antigua and Barbuda', + capital: "Saint John's", + languages: ['English'], + population: 86295, + flag: 'https://restcountries.eu/data/atg.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Argentina', + capital: 'Buenos Aires', + languages: ['Spanish', 'Guaraní'], + population: 43590400, + flag: 'https://restcountries.eu/data/arg.svg', + currency: 'Argentine peso' + }, + { + name: 'Armenia', + capital: 'Yerevan', + languages: ['Armenian', 'Russian'], + population: 2994400, + flag: 'https://restcountries.eu/data/arm.svg', + currency: 'Armenian dram' + }, + { + name: 'Aruba', + capital: 'Oranjestad', + languages: ['Dutch', '(Eastern) Punjabi'], + population: 107394, + flag: 'https://restcountries.eu/data/abw.svg', + currency: 'Aruban florin' + }, + { + name: 'Australia', + capital: 'Canberra', + languages: ['English'], + population: 24117360, + flag: 'https://restcountries.eu/data/aus.svg', + currency: 'Australian dollar' + }, + { + name: 'Austria', + capital: 'Vienna', + languages: ['German'], + population: 8725931, + flag: 'https://restcountries.eu/data/aut.svg', + currency: 'Euro' + }, + { + name: 'Azerbaijan', + capital: 'Baku', + languages: ['Azerbaijani'], + population: 9730500, + flag: 'https://restcountries.eu/data/aze.svg', + currency: 'Azerbaijani manat' + }, + { + name: 'Bahamas', + capital: 'Nassau', + languages: ['English'], + population: 378040, + flag: 'https://restcountries.eu/data/bhs.svg', + currency: 'Bahamian dollar' + }, + { + name: 'Bahrain', + capital: 'Manama', + languages: ['Arabic'], + population: 1404900, + flag: 'https://restcountries.eu/data/bhr.svg', + currency: 'Bahraini dinar' + }, + { + name: 'Bangladesh', + capital: 'Dhaka', + languages: ['Bengali'], + population: 161006790, + flag: 'https://restcountries.eu/data/bgd.svg', + currency: 'Bangladeshi taka' + }, + { + name: 'Barbados', + capital: 'Bridgetown', + languages: ['English'], + population: 285000, + flag: 'https://restcountries.eu/data/brb.svg', + currency: 'Barbadian dollar' + }, + { + name: 'Belarus', + capital: 'Minsk', + languages: ['Belarusian', 'Russian'], + population: 9498700, + flag: 'https://restcountries.eu/data/blr.svg', + currency: 'New Belarusian ruble' + }, + { + name: 'Belgium', + capital: 'Brussels', + languages: ['Dutch', 'French', 'German'], + population: 11319511, + flag: 'https://restcountries.eu/data/bel.svg', + currency: 'Euro' + }, + { + name: 'Belize', + capital: 'Belmopan', + languages: ['English', 'Spanish'], + population: 370300, + flag: 'https://restcountries.eu/data/blz.svg', + currency: 'Belize dollar' + }, + { + name: 'Benin', + capital: 'Porto-Novo', + languages: ['French'], + population: 10653654, + flag: 'https://restcountries.eu/data/ben.svg', + currency: 'West African CFA franc' + }, + { + name: 'Bermuda', + capital: 'Hamilton', + languages: ['English'], + population: 61954, + flag: 'https://restcountries.eu/data/bmu.svg', + currency: 'Bermudian dollar' + }, + { + name: 'Bhutan', + capital: 'Thimphu', + languages: ['Dzongkha'], + population: 775620, + flag: 'https://restcountries.eu/data/btn.svg', + currency: 'Bhutanese ngultrum' + }, + { + name: 'Bolivia (Plurinational State of)', + capital: 'Sucre', + languages: ['Spanish', 'Aymara', 'Quechua'], + population: 10985059, + flag: 'https://restcountries.eu/data/bol.svg', + currency: 'Bolivian boliviano' + }, + { + name: 'Bonaire, Sint Eustatius and Saba', + capital: 'Kralendijk', + languages: ['Dutch'], + population: 17408, + flag: 'https://restcountries.eu/data/bes.svg', + currency: 'United States dollar' + }, + { + name: 'Bosnia and Herzegovina', + capital: 'Sarajevo', + languages: ['Bosnian', 'Croatian', 'Serbian'], + population: 3531159, + flag: 'https://restcountries.eu/data/bih.svg', + currency: 'Bosnia and Herzegovina convertible mark' + }, + { + name: 'Botswana', + capital: 'Gaborone', + languages: ['English', 'Tswana'], + population: 2141206, + flag: 'https://restcountries.eu/data/bwa.svg', + currency: 'Botswana pula' + }, + { + name: 'Bouvet Island', + capital: '', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 0, + flag: 'https://restcountries.eu/data/bvt.svg', + currency: 'Norwegian krone' + }, + { + name: 'Brazil', + capital: 'Brasília', + languages: ['Portuguese'], + population: 206135893, + flag: 'https://restcountries.eu/data/bra.svg', + currency: 'Brazilian real' + }, + { + name: 'British Indian Ocean Territory', + capital: 'Diego Garcia', + languages: ['English'], + population: 3000, + flag: 'https://restcountries.eu/data/iot.svg', + currency: 'United States dollar' + }, + { + name: 'United States Minor Outlying Islands', + capital: '', + languages: ['English'], + population: 300, + flag: 'https://restcountries.eu/data/umi.svg', + currency: 'United States Dollar' + }, + { + name: 'Virgin Islands (British)', + capital: 'Road Town', + languages: ['English'], + population: 28514, + flag: 'https://restcountries.eu/data/vgb.svg', + currency: '[D]' + }, + { + name: 'Virgin Islands (U.S.)', + capital: 'Charlotte Amalie', + languages: ['English'], + population: 114743, + flag: 'https://restcountries.eu/data/vir.svg', + currency: 'United States dollar' + }, + { + name: 'Brunei Darussalam', + capital: 'Bandar Seri Begawan', + languages: ['Malay'], + population: 411900, + flag: 'https://restcountries.eu/data/brn.svg', + currency: 'Brunei dollar' + }, + { + name: 'Bulgaria', + capital: 'Sofia', + languages: ['Bulgarian'], + population: 7153784, + flag: 'https://restcountries.eu/data/bgr.svg', + currency: 'Bulgarian lev' + }, + { + name: 'Burkina Faso', + capital: 'Ouagadougou', + languages: ['French', 'Fula'], + population: 19034397, + flag: 'https://restcountries.eu/data/bfa.svg', + currency: 'West African CFA franc' + }, + { + name: 'Burundi', + capital: 'Bujumbura', + languages: ['French', 'Kirundi'], + population: 10114505, + flag: 'https://restcountries.eu/data/bdi.svg', + currency: 'Burundian franc' + }, + { + name: 'Cambodia', + capital: 'Phnom Penh', + languages: ['Khmer'], + population: 15626444, + flag: 'https://restcountries.eu/data/khm.svg', + currency: 'Cambodian riel' + }, + { + name: 'Cameroon', + capital: 'Yaoundé', + languages: ['English', 'French'], + population: 22709892, + flag: 'https://restcountries.eu/data/cmr.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Canada', + capital: 'Ottawa', + languages: ['English', 'French'], + population: 36155487, + flag: 'https://restcountries.eu/data/can.svg', + currency: 'Canadian dollar' + }, + { + name: 'Cabo Verde', + capital: 'Praia', + languages: ['Portuguese'], + population: 531239, + flag: 'https://restcountries.eu/data/cpv.svg', + currency: 'Cape Verdean escudo' + }, + { + name: 'Cayman Islands', + capital: 'George Town', + languages: ['English'], + population: 58238, + flag: 'https://restcountries.eu/data/cym.svg', + currency: 'Cayman Islands dollar' + }, + { + name: 'Central African Republic', + capital: 'Bangui', + languages: ['French', 'Sango'], + population: 4998000, + flag: 'https://restcountries.eu/data/caf.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chad', + capital: "N'Djamena", + languages: ['French', 'Arabic'], + population: 14497000, + flag: 'https://restcountries.eu/data/tcd.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chile', + capital: 'Santiago', + languages: ['Spanish'], + population: 18191900, + flag: 'https://restcountries.eu/data/chl.svg', + currency: 'Chilean peso' + }, + { + name: 'China', + capital: 'Beijing', + languages: ['Chinese'], + population: 1377422166, + flag: 'https://restcountries.eu/data/chn.svg', + currency: 'Chinese yuan' + }, + { + name: 'Christmas Island', + capital: 'Flying Fish Cove', + languages: ['English'], + population: 2072, + flag: 'https://restcountries.eu/data/cxr.svg', + currency: 'Australian dollar' + }, + { + name: 'Cocos (Keeling) Islands', + capital: 'West Island', + languages: ['English'], + population: 550, + flag: 'https://restcountries.eu/data/cck.svg', + currency: 'Australian dollar' + }, + { + name: 'Colombia', + capital: 'Bogotá', + languages: ['Spanish'], + population: 48759958, + flag: 'https://restcountries.eu/data/col.svg', + currency: 'Colombian peso' + }, + { + name: 'Comoros', + capital: 'Moroni', + languages: ['Arabic', 'French'], + population: 806153, + flag: 'https://restcountries.eu/data/com.svg', + currency: 'Comorian franc' + }, + { + name: 'Congo', + capital: 'Brazzaville', + languages: ['French', 'Lingala'], + population: 4741000, + flag: 'https://restcountries.eu/data/cog.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Congo (Democratic Republic of the)', + capital: 'Kinshasa', + languages: ['French', 'Lingala', 'Kongo', 'Swahili', 'Luba-Katanga'], + population: 85026000, + flag: 'https://restcountries.eu/data/cod.svg', + currency: 'Congolese franc' + }, + { + name: 'Cook Islands', + capital: 'Avarua', + languages: ['English'], + population: 18100, + flag: 'https://restcountries.eu/data/cok.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Costa Rica', + capital: 'San José', + languages: ['Spanish'], + population: 4890379, + flag: 'https://restcountries.eu/data/cri.svg', + currency: 'Costa Rican colón' + }, + { + name: 'Croatia', + capital: 'Zagreb', + languages: ['Croatian'], + population: 4190669, + flag: 'https://restcountries.eu/data/hrv.svg', + currency: 'Croatian kuna' + }, + { + name: 'Cuba', + capital: 'Havana', + languages: ['Spanish'], + population: 11239004, + flag: 'https://restcountries.eu/data/cub.svg', + currency: 'Cuban convertible peso' + }, + { + name: 'Curaçao', + capital: 'Willemstad', + languages: ['Dutch', '(Eastern) Punjabi', 'English'], + population: 154843, + flag: 'https://restcountries.eu/data/cuw.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Cyprus', + capital: 'Nicosia', + languages: ['Greek (modern)', 'Turkish', 'Armenian'], + population: 847000, + flag: 'https://restcountries.eu/data/cyp.svg', + currency: 'Euro' + }, + { + name: 'Czech Republic', + capital: 'Prague', + languages: ['Czech', 'Slovak'], + population: 10558524, + flag: 'https://restcountries.eu/data/cze.svg', + currency: 'Czech koruna' + }, + { + name: 'Denmark', + capital: 'Copenhagen', + languages: ['Danish'], + population: 5717014, + flag: 'https://restcountries.eu/data/dnk.svg', + currency: 'Danish krone' + }, + { + name: 'Djibouti', + capital: 'Djibouti', + languages: ['French', 'Arabic'], + population: 900000, + flag: 'https://restcountries.eu/data/dji.svg', + currency: 'Djiboutian franc' + }, + { + name: 'Dominica', + capital: 'Roseau', + languages: ['English'], + population: 71293, + flag: 'https://restcountries.eu/data/dma.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Dominican Republic', + capital: 'Santo Domingo', + languages: ['Spanish'], + population: 10075045, + flag: 'https://restcountries.eu/data/dom.svg', + currency: 'Dominican peso' + }, + { + name: 'Ecuador', + capital: 'Quito', + languages: ['Spanish'], + population: 16545799, + flag: 'https://restcountries.eu/data/ecu.svg', + currency: 'United States dollar' + }, + { + name: 'Egypt', + capital: 'Cairo', + languages: ['Arabic'], + population: 91290000, + flag: 'https://restcountries.eu/data/egy.svg', + currency: 'Egyptian pound' + }, + { + name: 'El Salvador', + capital: 'San Salvador', + languages: ['Spanish'], + population: 6520675, + flag: 'https://restcountries.eu/data/slv.svg', + currency: 'United States dollar' + }, + { + name: 'Equatorial Guinea', + capital: 'Malabo', + languages: ['Spanish', 'French'], + population: 1222442, + flag: 'https://restcountries.eu/data/gnq.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Eritrea', + capital: 'Asmara', + languages: ['Tigrinya', 'Arabic', 'English'], + population: 5352000, + flag: 'https://restcountries.eu/data/eri.svg', + currency: 'Eritrean nakfa' + }, + { + name: 'Estonia', + capital: 'Tallinn', + languages: ['Estonian'], + population: 1315944, + flag: 'https://restcountries.eu/data/est.svg', + currency: 'Euro' + }, + { + name: 'Ethiopia', + capital: 'Addis Ababa', + languages: ['Amharic'], + population: 92206005, + flag: 'https://restcountries.eu/data/eth.svg', + currency: 'Ethiopian birr' + }, + { + name: 'Falkland Islands (Malvinas)', + capital: 'Stanley', + languages: ['English'], + population: 2563, + flag: 'https://restcountries.eu/data/flk.svg', + currency: 'Falkland Islands pound' + }, + { + name: 'Faroe Islands', + capital: 'Tórshavn', + languages: ['Faroese'], + population: 49376, + flag: 'https://restcountries.eu/data/fro.svg', + currency: 'Danish krone' + }, + { + name: 'Fiji', + capital: 'Suva', + languages: ['English', 'Fijian', 'Hindi', 'Urdu'], + population: 867000, + flag: 'https://restcountries.eu/data/fji.svg', + currency: 'Fijian dollar' + }, + { + name: 'Finland', + capital: 'Helsinki', + languages: ['Finnish', 'Swedish'], + population: 5491817, + flag: 'https://restcountries.eu/data/fin.svg', + currency: 'Euro' + }, + { + name: 'France', + capital: 'Paris', + languages: ['French'], + population: 66710000, + flag: 'https://restcountries.eu/data/fra.svg', + currency: 'Euro' + }, + { + name: 'French Guiana', + capital: 'Cayenne', + languages: ['French'], + population: 254541, + flag: 'https://restcountries.eu/data/guf.svg', + currency: 'Euro' + }, + { + name: 'French Polynesia', + capital: 'Papeetē', + languages: ['French'], + population: 271800, + flag: 'https://restcountries.eu/data/pyf.svg', + currency: 'CFP franc' + }, + { + name: 'French Southern Territories', + capital: 'Port-aux-Français', + languages: ['French'], + population: 140, + flag: 'https://restcountries.eu/data/atf.svg', + currency: 'Euro' + }, + { + name: 'Gabon', + capital: 'Libreville', + languages: ['French'], + population: 1802278, + flag: 'https://restcountries.eu/data/gab.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Gambia', + capital: 'Banjul', + languages: ['English'], + population: 1882450, + flag: 'https://restcountries.eu/data/gmb.svg', + currency: 'Gambian dalasi' + }, + { + name: 'Georgia', + capital: 'Tbilisi', + languages: ['Georgian'], + population: 3720400, + flag: 'https://restcountries.eu/data/geo.svg', + currency: 'Georgian Lari' + }, + { + name: 'Germany', + capital: 'Berlin', + languages: ['German'], + population: 81770900, + flag: 'https://restcountries.eu/data/deu.svg', + currency: 'Euro' + }, + { + name: 'Ghana', + capital: 'Accra', + languages: ['English'], + population: 27670174, + flag: 'https://restcountries.eu/data/gha.svg', + currency: 'Ghanaian cedi' + }, + { + name: 'Gibraltar', + capital: 'Gibraltar', + languages: ['English'], + population: 33140, + flag: 'https://restcountries.eu/data/gib.svg', + currency: 'Gibraltar pound' + }, + { + name: 'Greece', + capital: 'Athens', + languages: ['Greek (modern)'], + population: 10858018, + flag: 'https://restcountries.eu/data/grc.svg', + currency: 'Euro' + }, + { + name: 'Greenland', + capital: 'Nuuk', + languages: ['Kalaallisut'], + population: 55847, + flag: 'https://restcountries.eu/data/grl.svg', + currency: 'Danish krone' + }, + { + name: 'Grenada', + capital: "St. George's", + languages: ['English'], + population: 103328, + flag: 'https://restcountries.eu/data/grd.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Guadeloupe', + capital: 'Basse-Terre', + languages: ['French'], + population: 400132, + flag: 'https://restcountries.eu/data/glp.svg', + currency: 'Euro' + }, + { + name: 'Guam', + capital: 'Hagåtña', + languages: ['English', 'Chamorro', 'Spanish'], + population: 184200, + flag: 'https://restcountries.eu/data/gum.svg', + currency: 'United States dollar' + }, + { + name: 'Guatemala', + capital: 'Guatemala City', + languages: ['Spanish'], + population: 16176133, + flag: 'https://restcountries.eu/data/gtm.svg', + currency: 'Guatemalan quetzal' + }, + { + name: 'Guernsey', + capital: 'St. Peter Port', + languages: ['English', 'French'], + population: 62999, + flag: 'https://restcountries.eu/data/ggy.svg', + currency: 'British pound' + }, + { + name: 'Guinea', + capital: 'Conakry', + languages: ['French', 'Fula'], + population: 12947000, + flag: 'https://restcountries.eu/data/gin.svg', + currency: 'Guinean franc' + }, + { + name: 'Guinea-Bissau', + capital: 'Bissau', + languages: ['Portuguese'], + population: 1547777, + flag: 'https://restcountries.eu/data/gnb.svg', + currency: 'West African CFA franc' + }, + { + name: 'Guyana', + capital: 'Georgetown', + languages: ['English'], + population: 746900, + flag: 'https://restcountries.eu/data/guy.svg', + currency: 'Guyanese dollar' + }, + { + name: 'Haiti', + capital: 'Port-au-Prince', + languages: ['French', 'Haitian'], + population: 11078033, + flag: 'https://restcountries.eu/data/hti.svg', + currency: 'Haitian gourde' + }, + { + name: 'Heard Island and McDonald Islands', + capital: '', + languages: ['English'], + population: 0, + flag: 'https://restcountries.eu/data/hmd.svg', + currency: 'Australian dollar' + }, + { + name: 'Holy See', + capital: 'Rome', + languages: ['Latin', 'Italian', 'French', 'German'], + population: 451, + flag: 'https://restcountries.eu/data/vat.svg', + currency: 'Euro' + }, + { + name: 'Honduras', + capital: 'Tegucigalpa', + languages: ['Spanish'], + population: 8576532, + flag: 'https://restcountries.eu/data/hnd.svg', + currency: 'Honduran lempira' + }, + { + name: 'Hong Kong', + capital: 'City of Victoria', + languages: ['English', 'Chinese'], + population: 7324300, + flag: 'https://restcountries.eu/data/hkg.svg', + currency: 'Hong Kong dollar' + }, + { + name: 'Hungary', + capital: 'Budapest', + languages: ['Hungarian'], + population: 9823000, + flag: 'https://restcountries.eu/data/hun.svg', + currency: 'Hungarian forint' + }, + { + name: 'Iceland', + capital: 'Reykjavík', + languages: ['Icelandic'], + population: 334300, + flag: 'https://restcountries.eu/data/isl.svg', + currency: 'Icelandic króna' + }, + { + name: 'India', + capital: 'New Delhi', + languages: ['Hindi', 'English'], + population: 1295210000, + flag: 'https://restcountries.eu/data/ind.svg', + currency: 'Indian rupee' + }, + { + name: 'Indonesia', + capital: 'Jakarta', + languages: ['Indonesian'], + population: 258705000, + flag: 'https://restcountries.eu/data/idn.svg', + currency: 'Indonesian rupiah' + }, + { + name: "Côte d'Ivoire", + capital: 'Yamoussoukro', + languages: ['French'], + population: 22671331, + flag: 'https://restcountries.eu/data/civ.svg', + currency: 'West African CFA franc' + }, + { + name: 'Iran (Islamic Republic of)', + capital: 'Tehran', + languages: ['Persian (Farsi)'], + population: 79369900, + flag: 'https://restcountries.eu/data/irn.svg', + currency: 'Iranian rial' + }, + { + name: 'Iraq', + capital: 'Baghdad', + languages: ['Arabic', 'Kurdish'], + population: 37883543, + flag: 'https://restcountries.eu/data/irq.svg', + currency: 'Iraqi dinar' + }, + { + name: 'Ireland', + capital: 'Dublin', + languages: ['Irish', 'English'], + population: 6378000, + flag: 'https://restcountries.eu/data/irl.svg', + currency: 'Euro' + }, + { + name: 'Isle of Man', + capital: 'Douglas', + languages: ['English', 'Manx'], + population: 84497, + flag: 'https://restcountries.eu/data/imn.svg', + currency: 'British pound' + }, + { + name: 'Israel', + capital: 'Jerusalem', + languages: ['Hebrew (modern)', 'Arabic'], + population: 8527400, + flag: 'https://restcountries.eu/data/isr.svg', + currency: 'Israeli new shekel' + }, + { + name: 'Italy', + capital: 'Rome', + languages: ['Italian'], + population: 60665551, + flag: 'https://restcountries.eu/data/ita.svg', + currency: 'Euro' + }, + { + name: 'Jamaica', + capital: 'Kingston', + languages: ['English'], + population: 2723246, + flag: 'https://restcountries.eu/data/jam.svg', + currency: 'Jamaican dollar' + }, + { + name: 'Japan', + capital: 'Tokyo', + languages: ['Japanese'], + population: 126960000, + flag: 'https://restcountries.eu/data/jpn.svg', + currency: 'Japanese yen' + }, + { + name: 'Jersey', + capital: 'Saint Helier', + languages: ['English', 'French'], + population: 100800, + flag: 'https://restcountries.eu/data/jey.svg', + currency: 'British pound' + }, + { + name: 'Jordan', + capital: 'Amman', + languages: ['Arabic'], + population: 9531712, + flag: 'https://restcountries.eu/data/jor.svg', + currency: 'Jordanian dinar' + }, + { + name: 'Kazakhstan', + capital: 'Astana', + languages: ['Kazakh', 'Russian'], + population: 17753200, + flag: 'https://restcountries.eu/data/kaz.svg', + currency: 'Kazakhstani tenge' + }, + { + name: 'Kenya', + capital: 'Nairobi', + languages: ['English', 'Swahili'], + population: 47251000, + flag: 'https://restcountries.eu/data/ken.svg', + currency: 'Kenyan shilling' + }, + { + name: 'Kiribati', + capital: 'South Tarawa', + languages: ['English'], + population: 113400, + flag: 'https://restcountries.eu/data/kir.svg', + currency: 'Australian dollar' + }, + { + name: 'Kuwait', + capital: 'Kuwait City', + languages: ['Arabic'], + population: 4183658, + flag: 'https://restcountries.eu/data/kwt.svg', + currency: 'Kuwaiti dinar' + }, + { + name: 'Kyrgyzstan', + capital: 'Bishkek', + languages: ['Kyrgyz', 'Russian'], + population: 6047800, + flag: 'https://restcountries.eu/data/kgz.svg', + currency: 'Kyrgyzstani som' + }, + { + name: "Lao People's Democratic Republic", + capital: 'Vientiane', + languages: ['Lao'], + population: 6492400, + flag: 'https://restcountries.eu/data/lao.svg', + currency: 'Lao kip' + }, + { + name: 'Latvia', + capital: 'Riga', + languages: ['Latvian'], + population: 1961600, + flag: 'https://restcountries.eu/data/lva.svg', + currency: 'Euro' + }, + { + name: 'Lebanon', + capital: 'Beirut', + languages: ['Arabic', 'French'], + population: 5988000, + flag: 'https://restcountries.eu/data/lbn.svg', + currency: 'Lebanese pound' + }, + { + name: 'Lesotho', + capital: 'Maseru', + languages: ['English', 'Southern Sotho'], + population: 1894194, + flag: 'https://restcountries.eu/data/lso.svg', + currency: 'Lesotho loti' + }, + { + name: 'Liberia', + capital: 'Monrovia', + languages: ['English'], + population: 4615000, + flag: 'https://restcountries.eu/data/lbr.svg', + currency: 'Liberian dollar' + }, + { + name: 'Libya', + capital: 'Tripoli', + languages: ['Arabic'], + population: 6385000, + flag: 'https://restcountries.eu/data/lby.svg', + currency: 'Libyan dinar' + }, + { + name: 'Liechtenstein', + capital: 'Vaduz', + languages: ['German'], + population: 37623, + flag: 'https://restcountries.eu/data/lie.svg', + currency: 'Swiss franc' + }, + { + name: 'Lithuania', + capital: 'Vilnius', + languages: ['Lithuanian'], + population: 2872294, + flag: 'https://restcountries.eu/data/ltu.svg', + currency: 'Euro' + }, + { + name: 'Luxembourg', + capital: 'Luxembourg', + languages: ['French', 'German', 'Luxembourgish'], + population: 576200, + flag: 'https://restcountries.eu/data/lux.svg', + currency: 'Euro' + }, + { + name: 'Macao', + capital: '', + languages: ['Chinese', 'Portuguese'], + population: 649100, + flag: 'https://restcountries.eu/data/mac.svg', + currency: 'Macanese pataca' + }, + { + name: 'Macedonia (the former Yugoslav Republic of)', + capital: 'Skopje', + languages: ['Macedonian'], + population: 2058539, + flag: 'https://restcountries.eu/data/mkd.svg', + currency: 'Macedonian denar' + }, + { + name: 'Madagascar', + capital: 'Antananarivo', + languages: ['French', 'Malagasy'], + population: 22434363, + flag: 'https://restcountries.eu/data/mdg.svg', + currency: 'Malagasy ariary' + }, + { + name: 'Malawi', + capital: 'Lilongwe', + languages: ['English', 'Chichewa'], + population: 16832910, + flag: 'https://restcountries.eu/data/mwi.svg', + currency: 'Malawian kwacha' + }, + { + name: 'Malaysia', + capital: 'Kuala Lumpur', + languages: ['Malaysian'], + population: 31405416, + flag: 'https://restcountries.eu/data/mys.svg', + currency: 'Malaysian ringgit' + }, + { + name: 'Maldives', + capital: 'Malé', + languages: ['Divehi'], + population: 344023, + flag: 'https://restcountries.eu/data/mdv.svg', + currency: 'Maldivian rufiyaa' + }, + { + name: 'Mali', + capital: 'Bamako', + languages: ['French'], + population: 18135000, + flag: 'https://restcountries.eu/data/mli.svg', + currency: 'West African CFA franc' + }, + { + name: 'Malta', + capital: 'Valletta', + languages: ['Maltese', 'English'], + population: 425384, + flag: 'https://restcountries.eu/data/mlt.svg', + currency: 'Euro' + }, + { + name: 'Marshall Islands', + capital: 'Majuro', + languages: ['English', 'Marshallese'], + population: 54880, + flag: 'https://restcountries.eu/data/mhl.svg', + currency: 'United States dollar' + }, + { + name: 'Martinique', + capital: 'Fort-de-France', + languages: ['French'], + population: 378243, + flag: 'https://restcountries.eu/data/mtq.svg', + currency: 'Euro' + }, + { + name: 'Mauritania', + capital: 'Nouakchott', + languages: ['Arabic'], + population: 3718678, + flag: 'https://restcountries.eu/data/mrt.svg', + currency: 'Mauritanian ouguiya' + }, + { + name: 'Mauritius', + capital: 'Port Louis', + languages: ['English'], + population: 1262879, + flag: 'https://restcountries.eu/data/mus.svg', + currency: 'Mauritian rupee' + }, + { + name: 'Mayotte', + capital: 'Mamoudzou', + languages: ['French'], + population: 226915, + flag: 'https://restcountries.eu/data/myt.svg', + currency: 'Euro' + }, + { + name: 'Mexico', + capital: 'Mexico City', + languages: ['Spanish'], + population: 122273473, + flag: 'https://restcountries.eu/data/mex.svg', + currency: 'Mexican peso' + }, + { + name: 'Micronesia (Federated States of)', + capital: 'Palikir', + languages: ['English'], + population: 102800, + flag: 'https://restcountries.eu/data/fsm.svg', + currency: '[D]' + }, + { + name: 'Moldova (Republic of)', + capital: 'Chișinău', + languages: ['Romanian'], + population: 3553100, + flag: 'https://restcountries.eu/data/mda.svg', + currency: 'Moldovan leu' + }, + { + name: 'Monaco', + capital: 'Monaco', + languages: ['French'], + population: 38400, + flag: 'https://restcountries.eu/data/mco.svg', + currency: 'Euro' + }, + { + name: 'Mongolia', + capital: 'Ulan Bator', + languages: ['Mongolian'], + population: 3093100, + flag: 'https://restcountries.eu/data/mng.svg', + currency: 'Mongolian tögrög' + }, + { + name: 'Montenegro', + capital: 'Podgorica', + languages: ['Serbian', 'Bosnian', 'Albanian', 'Croatian'], + population: 621810, + flag: 'https://restcountries.eu/data/mne.svg', + currency: 'Euro' + }, + { + name: 'Montserrat', + capital: 'Plymouth', + languages: ['English'], + population: 4922, + flag: 'https://restcountries.eu/data/msr.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Morocco', + capital: 'Rabat', + languages: ['Arabic'], + population: 33337529, + flag: 'https://restcountries.eu/data/mar.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Mozambique', + capital: 'Maputo', + languages: ['Portuguese'], + population: 26423700, + flag: 'https://restcountries.eu/data/moz.svg', + currency: 'Mozambican metical' + }, + { + name: 'Myanmar', + capital: 'Naypyidaw', + languages: ['Burmese'], + population: 51419420, + flag: 'https://restcountries.eu/data/mmr.svg', + currency: 'Burmese kyat' + }, + { + name: 'Namibia', + capital: 'Windhoek', + languages: ['English', 'Afrikaans'], + population: 2324388, + flag: 'https://restcountries.eu/data/nam.svg', + currency: 'Namibian dollar' + }, + { + name: 'Nauru', + capital: 'Yaren', + languages: ['English', 'Nauruan'], + population: 10084, + flag: 'https://restcountries.eu/data/nru.svg', + currency: 'Australian dollar' + }, + { + name: 'Nepal', + capital: 'Kathmandu', + languages: ['Nepali'], + population: 28431500, + flag: 'https://restcountries.eu/data/npl.svg', + currency: 'Nepalese rupee' + }, + { + name: 'Netherlands', + capital: 'Amsterdam', + languages: ['Dutch'], + population: 17019800, + flag: 'https://restcountries.eu/data/nld.svg', + currency: 'Euro' + }, + { + name: 'New Caledonia', + capital: 'Nouméa', + languages: ['French'], + population: 268767, + flag: 'https://restcountries.eu/data/ncl.svg', + currency: 'CFP franc' + }, + { + name: 'New Zealand', + capital: 'Wellington', + languages: ['English', 'Māori'], + population: 4697854, + flag: 'https://restcountries.eu/data/nzl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Nicaragua', + capital: 'Managua', + languages: ['Spanish'], + population: 6262703, + flag: 'https://restcountries.eu/data/nic.svg', + currency: 'Nicaraguan córdoba' + }, + { + name: 'Niger', + capital: 'Niamey', + languages: ['French'], + population: 20715000, + flag: 'https://restcountries.eu/data/ner.svg', + currency: 'West African CFA franc' + }, + { + name: 'Nigeria', + capital: 'Abuja', + languages: ['English'], + population: 186988000, + flag: 'https://restcountries.eu/data/nga.svg', + currency: 'Nigerian naira' + }, + { + name: 'Niue', + capital: 'Alofi', + languages: ['English'], + population: 1470, + flag: 'https://restcountries.eu/data/niu.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Norfolk Island', + capital: 'Kingston', + languages: ['English'], + population: 2302, + flag: 'https://restcountries.eu/data/nfk.svg', + currency: 'Australian dollar' + }, + { + name: "Korea (Democratic People's Republic of)", + capital: 'Pyongyang', + languages: ['Korean'], + population: 25281000, + flag: 'https://restcountries.eu/data/prk.svg', + currency: 'North Korean won' + }, + { + name: 'Northern Mariana Islands', + capital: 'Saipan', + languages: ['English', 'Chamorro'], + population: 56940, + flag: 'https://restcountries.eu/data/mnp.svg', + currency: 'United States dollar' + }, + { + name: 'Norway', + capital: 'Oslo', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 5223256, + flag: 'https://restcountries.eu/data/nor.svg', + currency: 'Norwegian krone' + }, + { + name: 'Oman', + capital: 'Muscat', + languages: ['Arabic'], + population: 4420133, + flag: 'https://restcountries.eu/data/omn.svg', + currency: 'Omani rial' + }, + { + name: 'Pakistan', + capital: 'Islamabad', + languages: ['English', 'Urdu'], + population: 194125062, + flag: 'https://restcountries.eu/data/pak.svg', + currency: 'Pakistani rupee' + }, + { + name: 'Palau', + capital: 'Ngerulmud', + languages: ['English'], + population: 17950, + flag: 'https://restcountries.eu/data/plw.svg', + currency: '[E]' + }, + { + name: 'Palestine, State of', + capital: 'Ramallah', + languages: ['Arabic'], + population: 4682467, + flag: 'https://restcountries.eu/data/pse.svg', + currency: 'Israeli new sheqel' + }, + { + name: 'Panama', + capital: 'Panama City', + languages: ['Spanish'], + population: 3814672, + flag: 'https://restcountries.eu/data/pan.svg', + currency: 'Panamanian balboa' + }, + { + name: 'Papua New Guinea', + capital: 'Port Moresby', + languages: ['English'], + population: 8083700, + flag: 'https://restcountries.eu/data/png.svg', + currency: 'Papua New Guinean kina' + }, + { + name: 'Paraguay', + capital: 'Asunción', + languages: ['Spanish', 'Guaraní'], + population: 6854536, + flag: 'https://restcountries.eu/data/pry.svg', + currency: 'Paraguayan guaraní' + }, + { + name: 'Peru', + capital: 'Lima', + languages: ['Spanish'], + population: 31488700, + flag: 'https://restcountries.eu/data/per.svg', + currency: 'Peruvian sol' + }, + { + name: 'Philippines', + capital: 'Manila', + languages: ['English'], + population: 103279800, + flag: 'https://restcountries.eu/data/phl.svg', + currency: 'Philippine peso' + }, + { + name: 'Pitcairn', + capital: 'Adamstown', + languages: ['English'], + population: 56, + flag: 'https://restcountries.eu/data/pcn.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Poland', + capital: 'Warsaw', + languages: ['Polish'], + population: 38437239, + flag: 'https://restcountries.eu/data/pol.svg', + currency: 'Polish złoty' + }, + { + name: 'Portugal', + capital: 'Lisbon', + languages: ['Portuguese'], + population: 10374822, + flag: 'https://restcountries.eu/data/prt.svg', + currency: 'Euro' + }, + { + name: 'Puerto Rico', + capital: 'San Juan', + languages: ['Spanish', 'English'], + population: 3474182, + flag: 'https://restcountries.eu/data/pri.svg', + currency: 'United States dollar' + }, + { + name: 'Qatar', + capital: 'Doha', + languages: ['Arabic'], + population: 2587564, + flag: 'https://restcountries.eu/data/qat.svg', + currency: 'Qatari riyal' + }, + { + name: 'Republic of Kosovo', + capital: 'Pristina', + languages: ['Albanian', 'Serbian'], + population: 1733842, + flag: 'https://restcountries.eu/data/kos.svg', + currency: 'Euro' + }, + { + name: 'Réunion', + capital: 'Saint-Denis', + languages: ['French'], + population: 840974, + flag: 'https://restcountries.eu/data/reu.svg', + currency: 'Euro' + }, + { + name: 'Romania', + capital: 'Bucharest', + languages: ['Romanian'], + population: 19861408, + flag: 'https://restcountries.eu/data/rou.svg', + currency: 'Romanian leu' + }, + { + name: 'Russian Federation', + capital: 'Moscow', + languages: ['Russian'], + population: 146599183, + flag: 'https://restcountries.eu/data/rus.svg', + currency: 'Russian ruble' + }, + { + name: 'Rwanda', + capital: 'Kigali', + languages: ['Kinyarwanda', 'English', 'French'], + population: 11553188, + flag: 'https://restcountries.eu/data/rwa.svg', + currency: 'Rwandan franc' + }, + { + name: 'Saint Barthélemy', + capital: 'Gustavia', + languages: ['French'], + population: 9417, + flag: 'https://restcountries.eu/data/blm.svg', + currency: 'Euro' + }, + { + name: 'Saint Helena, Ascension and Tristan da Cunha', + capital: 'Jamestown', + languages: ['English'], + population: 4255, + flag: 'https://restcountries.eu/data/shn.svg', + currency: 'Saint Helena pound' + }, + { + name: 'Saint Kitts and Nevis', + capital: 'Basseterre', + languages: ['English'], + population: 46204, + flag: 'https://restcountries.eu/data/kna.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Lucia', + capital: 'Castries', + languages: ['English'], + population: 186000, + flag: 'https://restcountries.eu/data/lca.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Martin (French part)', + capital: 'Marigot', + languages: ['English', 'French', 'Dutch'], + population: 36979, + flag: 'https://restcountries.eu/data/maf.svg', + currency: 'Euro' + }, + { + name: 'Saint Pierre and Miquelon', + capital: 'Saint-Pierre', + languages: ['French'], + population: 6069, + flag: 'https://restcountries.eu/data/spm.svg', + currency: 'Euro' + }, + { + name: 'Saint Vincent and the Grenadines', + capital: 'Kingstown', + languages: ['English'], + population: 109991, + flag: 'https://restcountries.eu/data/vct.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Samoa', + capital: 'Apia', + languages: ['Samoan', 'English'], + population: 194899, + flag: 'https://restcountries.eu/data/wsm.svg', + currency: 'Samoan tālā' + }, + { + name: 'San Marino', + capital: 'City of San Marino', + languages: ['Italian'], + population: 33005, + flag: 'https://restcountries.eu/data/smr.svg', + currency: 'Euro' + }, + { + name: 'Sao Tome and Principe', + capital: 'São Tomé', + languages: ['Portuguese'], + population: 187356, + flag: 'https://restcountries.eu/data/stp.svg', + currency: 'São Tomé and Príncipe dobra' + }, + { + name: 'Saudi Arabia', + capital: 'Riyadh', + languages: ['Arabic'], + population: 32248200, + flag: 'https://restcountries.eu/data/sau.svg', + currency: 'Saudi riyal' + }, + { + name: 'Senegal', + capital: 'Dakar', + languages: ['French'], + population: 14799859, + flag: 'https://restcountries.eu/data/sen.svg', + currency: 'West African CFA franc' + }, + { + name: 'Serbia', + capital: 'Belgrade', + languages: ['Serbian'], + population: 7076372, + flag: 'https://restcountries.eu/data/srb.svg', + currency: 'Serbian dinar' + }, + { + name: 'Seychelles', + capital: 'Victoria', + languages: ['French', 'English'], + population: 91400, + flag: 'https://restcountries.eu/data/syc.svg', + currency: 'Seychellois rupee' + }, + { + name: 'Sierra Leone', + capital: 'Freetown', + languages: ['English'], + population: 7075641, + flag: 'https://restcountries.eu/data/sle.svg', + currency: 'Sierra Leonean leone' + }, + { + name: 'Singapore', + capital: 'Singapore', + languages: ['English', 'Malay', 'Tamil', 'Chinese'], + population: 5535000, + flag: 'https://restcountries.eu/data/sgp.svg', + currency: 'Brunei dollar' + }, + { + name: 'Sint Maarten (Dutch part)', + capital: 'Philipsburg', + languages: ['Dutch', 'English'], + population: 38247, + flag: 'https://restcountries.eu/data/sxm.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Slovakia', + capital: 'Bratislava', + languages: ['Slovak'], + population: 5426252, + flag: 'https://restcountries.eu/data/svk.svg', + currency: 'Euro' + }, + { + name: 'Slovenia', + capital: 'Ljubljana', + languages: ['Slovene'], + population: 2064188, + flag: 'https://restcountries.eu/data/svn.svg', + currency: 'Euro' + }, + { + name: 'Solomon Islands', + capital: 'Honiara', + languages: ['English'], + population: 642000, + flag: 'https://restcountries.eu/data/slb.svg', + currency: 'Solomon Islands dollar' + }, + { + name: 'Somalia', + capital: 'Mogadishu', + languages: ['Somali', 'Arabic'], + population: 11079000, + flag: 'https://restcountries.eu/data/som.svg', + currency: 'Somali shilling' + }, + { + name: 'South Africa', + capital: 'Pretoria', + languages: [ + 'Afrikaans', + 'English', + 'Southern Ndebele', + 'Southern Sotho', + 'Swati', + 'Tswana', + 'Tsonga', + 'Venda', + 'Xhosa', + 'Zulu' + ], + population: 55653654, + flag: 'https://restcountries.eu/data/zaf.svg', + currency: 'South African rand' + }, + { + name: 'South Georgia and the South Sandwich Islands', + capital: 'King Edward Point', + languages: ['English'], + population: 30, + flag: 'https://restcountries.eu/data/sgs.svg', + currency: 'British pound' + }, + { + name: 'Korea (Republic of)', + capital: 'Seoul', + languages: ['Korean'], + population: 50801405, + flag: 'https://restcountries.eu/data/kor.svg', + currency: 'South Korean won' + }, + { + name: 'South Sudan', + capital: 'Juba', + languages: ['English'], + population: 12131000, + flag: 'https://restcountries.eu/data/ssd.svg', + currency: 'South Sudanese pound' + }, + { + name: 'Spain', + capital: 'Madrid', + languages: ['Spanish'], + population: 46438422, + flag: 'https://restcountries.eu/data/esp.svg', + currency: 'Euro' + }, + { + name: 'Sri Lanka', + capital: 'Colombo', + languages: ['Sinhalese', 'Tamil'], + population: 20966000, + flag: 'https://restcountries.eu/data/lka.svg', + currency: 'Sri Lankan rupee' + }, + { + name: 'Sudan', + capital: 'Khartoum', + languages: ['Arabic', 'English'], + population: 39598700, + flag: 'https://restcountries.eu/data/sdn.svg', + currency: 'Sudanese pound' + }, + { + name: 'Suriname', + capital: 'Paramaribo', + languages: ['Dutch'], + population: 541638, + flag: 'https://restcountries.eu/data/sur.svg', + currency: 'Surinamese dollar' + }, + { + name: 'Svalbard and Jan Mayen', + capital: 'Longyearbyen', + languages: ['Norwegian'], + population: 2562, + flag: 'https://restcountries.eu/data/sjm.svg', + currency: 'Norwegian krone' + }, + { + name: 'Swaziland', + capital: 'Lobamba', + languages: ['English', 'Swati'], + population: 1132657, + flag: 'https://restcountries.eu/data/swz.svg', + currency: 'Swazi lilangeni' + }, + { + name: 'Sweden', + capital: 'Stockholm', + languages: ['Swedish'], + population: 9894888, + flag: 'https://restcountries.eu/data/swe.svg', + currency: 'Swedish krona' + }, + { + name: 'Switzerland', + capital: 'Bern', + languages: ['German', 'French', 'Italian'], + population: 8341600, + flag: 'https://restcountries.eu/data/che.svg', + currency: 'Swiss franc' + }, + { + name: 'Syrian Arab Republic', + capital: 'Damascus', + languages: ['Arabic'], + population: 18564000, + flag: 'https://restcountries.eu/data/syr.svg', + currency: 'Syrian pound' + }, + { + name: 'Taiwan', + capital: 'Taipei', + languages: ['Chinese'], + population: 23503349, + flag: 'https://restcountries.eu/data/twn.svg', + currency: 'New Taiwan dollar' + }, + { + name: 'Tajikistan', + capital: 'Dushanbe', + languages: ['Tajik', 'Russian'], + population: 8593600, + flag: 'https://restcountries.eu/data/tjk.svg', + currency: 'Tajikistani somoni' + }, + { + name: 'Tanzania, United Republic of', + capital: 'Dodoma', + languages: ['Swahili', 'English'], + population: 55155000, + flag: 'https://restcountries.eu/data/tza.svg', + currency: 'Tanzanian shilling' + }, + { + name: 'Thailand', + capital: 'Bangkok', + languages: ['Thai'], + population: 65327652, + flag: 'https://restcountries.eu/data/tha.svg', + currency: 'Thai baht' + }, + { + name: 'Timor-Leste', + capital: 'Dili', + languages: ['Portuguese'], + population: 1167242, + flag: 'https://restcountries.eu/data/tls.svg', + currency: 'United States dollar' + }, + { + name: 'Togo', + capital: 'Lomé', + languages: ['French'], + population: 7143000, + flag: 'https://restcountries.eu/data/tgo.svg', + currency: 'West African CFA franc' + }, + { + name: 'Tokelau', + capital: 'Fakaofo', + languages: ['English'], + population: 1411, + flag: 'https://restcountries.eu/data/tkl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Tonga', + capital: "Nuku'alofa", + languages: ['English', 'Tonga (Tonga Islands)'], + population: 103252, + flag: 'https://restcountries.eu/data/ton.svg', + currency: 'Tongan paʻanga' + }, + { + name: 'Trinidad and Tobago', + capital: 'Port of Spain', + languages: ['English'], + population: 1349667, + flag: 'https://restcountries.eu/data/tto.svg', + currency: 'Trinidad and Tobago dollar' + }, + { + name: 'Tunisia', + capital: 'Tunis', + languages: ['Arabic'], + population: 11154400, + flag: 'https://restcountries.eu/data/tun.svg', + currency: 'Tunisian dinar' + }, + { + name: 'Turkey', + capital: 'Ankara', + languages: ['Turkish'], + population: 78741053, + flag: 'https://restcountries.eu/data/tur.svg', + currency: 'Turkish lira' + }, + { + name: 'Turkmenistan', + capital: 'Ashgabat', + languages: ['Turkmen', 'Russian'], + population: 4751120, + flag: 'https://restcountries.eu/data/tkm.svg', + currency: 'Turkmenistan manat' + }, + { + name: 'Turks and Caicos Islands', + capital: 'Cockburn Town', + languages: ['English'], + population: 31458, + flag: 'https://restcountries.eu/data/tca.svg', + currency: 'United States dollar' + }, + { + name: 'Tuvalu', + capital: 'Funafuti', + languages: ['English'], + population: 10640, + flag: 'https://restcountries.eu/data/tuv.svg', + currency: 'Australian dollar' + }, + { + name: 'Uganda', + capital: 'Kampala', + languages: ['English', 'Swahili'], + population: 33860700, + flag: 'https://restcountries.eu/data/uga.svg', + currency: 'Ugandan shilling' + }, + { + name: 'Ukraine', + capital: 'Kiev', + languages: ['Ukrainian'], + population: 42692393, + flag: 'https://restcountries.eu/data/ukr.svg', + currency: 'Ukrainian hryvnia' + }, + { + name: 'United Arab Emirates', + capital: 'Abu Dhabi', + languages: ['Arabic'], + population: 9856000, + flag: 'https://restcountries.eu/data/are.svg', + currency: 'United Arab Emirates dirham' + }, + { + name: 'United Kingdom of Great Britain and Northern Ireland', + capital: 'London', + languages: ['English'], + population: 65110000, + flag: 'https://restcountries.eu/data/gbr.svg', + currency: 'British pound' + }, + { + name: 'United States of America', + capital: 'Washington, D.C.', + languages: ['English'], + population: 323947000, + flag: 'https://restcountries.eu/data/usa.svg', + currency: 'United States dollar' + }, + { + name: 'Uruguay', + capital: 'Montevideo', + languages: ['Spanish'], + population: 3480222, + flag: 'https://restcountries.eu/data/ury.svg', + currency: 'Uruguayan peso' + }, + { + name: 'Uzbekistan', + capital: 'Tashkent', + languages: ['Uzbek', 'Russian'], + population: 31576400, + flag: 'https://restcountries.eu/data/uzb.svg', + currency: "Uzbekistani so'm" + }, + { + name: 'Vanuatu', + capital: 'Port Vila', + languages: ['Bislama', 'English', 'French'], + population: 277500, + flag: 'https://restcountries.eu/data/vut.svg', + currency: 'Vanuatu vatu' + }, + { + name: 'Venezuela (Bolivarian Republic of)', + capital: 'Caracas', + languages: ['Spanish'], + population: 31028700, + flag: 'https://restcountries.eu/data/ven.svg', + currency: 'Venezuelan bolívar' + }, + { + name: 'Viet Nam', + capital: 'Hanoi', + languages: ['Vietnamese'], + population: 92700000, + flag: 'https://restcountries.eu/data/vnm.svg', + currency: 'Vietnamese đồng' + }, + { + name: 'Wallis and Futuna', + capital: 'Mata-Utu', + languages: ['French'], + population: 11750, + flag: 'https://restcountries.eu/data/wlf.svg', + currency: 'CFP franc' + }, + { + name: 'Western Sahara', + capital: 'El Aaiún', + languages: ['Spanish'], + population: 510713, + flag: 'https://restcountries.eu/data/esh.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Yemen', + capital: "Sana'a", + languages: ['Arabic'], + population: 27478000, + flag: 'https://restcountries.eu/data/yem.svg', + currency: 'Yemeni rial' + }, + { + name: 'Zambia', + capital: 'Lusaka', + languages: ['English'], + population: 15933883, + flag: 'https://restcountries.eu/data/zmb.svg', + currency: 'Zambian kwacha' + }, + { + name: 'Zimbabwe', + capital: 'Harare', + languages: ['English', 'Shona', 'Northern Ndebele'], + population: 14240168, + flag: 'https://restcountries.eu/data/zwe.svg', + currency: 'Botswana pula' + } +] diff --git a/25_Day_World_countries_data_visualization_1/25_day_starter/index.html b/25_Day_World_countries_data_visualization_1/25_day_starter/index.html new file mode 100644 index 0000000..aba231b --- /dev/null +++ b/25_Day_World_countries_data_visualization_1/25_day_starter/index.html @@ -0,0 +1,38 @@ + + + + + + + + World Countries Data + + + + + +
    +

    World Countries Data

    +

    + +
    +
    + +
    +
    + + +
    +

    +
    +
    +
    +
    +
    + + + + + + + \ No newline at end of file diff --git a/25_Day_World_countries_data_visualization_1/25_day_starter/scripts/main.js b/25_Day_World_countries_data_visualization_1/25_day_starter/scripts/main.js new file mode 100644 index 0000000..c6045c8 --- /dev/null +++ b/25_Day_World_countries_data_visualization_1/25_day_starter/scripts/main.js @@ -0,0 +1,2 @@ +console.log(countries) +alert('Open the console and check if the countries has been loaded') \ No newline at end of file diff --git a/25_Day_World_countries_data_visualization_1/25_day_world_countries_data_visualization_1.md b/25_Day_World_countries_data_visualization_1/25_day_world_countries_data_visualization_1.md new file mode 100644 index 0000000..f923496 --- /dev/null +++ b/25_Day_World_countries_data_visualization_1/25_day_world_countries_data_visualization_1.md @@ -0,0 +1,39 @@ +
    +

    30 Days Of JavaScript: World Countrires Data Visualization

    + + + + + Twitter Follow + + +Author: +Asabeneh Yetayeh
    + January, 2020 +
    + +
    + +[<< Day 24](../24_Day_Project_soloar_system/24_day_project_soloar_system.md) | [Day 26 >>](../26_Day_World_countries_data_visualization_2/26_day_world_countries_data_visualization_2.md) + +![Thirty Days Of JavaScript](../images/banners/day_1_25.png) + +- [Day 25](#day-25) + - [Exercises](#exercises) + - [Exercise: Level 1](#exercise-level-1) + +# Day 25 + +## Exercises + +### Exercise: Level 1 + +1. Visualize the ten most populated countries and the ten most spoken languages in the world using DOM(HTML, CSS, JS) + +![Bar Graph](./../images/projects/dom_min_project_bar_graph_day_5.1.gif) + +![Bar Graph](./../images/projects/dom_min_project_bar_graph_day_5.1.png) + +🎉 CONGRATULATIONS ! 🎉 + +[<< Day 24](../24_Day_Project_soloar_system/24_day_project_soloar_system.md) | [Day 26 >>](../26_Day_World_countries_data_visualization_2/26_day_world_countries_data_visualization_2.md) diff --git a/26_Day_World_countries_data_visualization_2/26_day_starter/data/countries.js b/26_Day_World_countries_data_visualization_2/26_day_starter/data/countries.js new file mode 100644 index 0000000..e57b005 --- /dev/null +++ b/26_Day_World_countries_data_visualization_2/26_day_starter/data/countries.js @@ -0,0 +1,195 @@ +const countries = [ + 'Afghanistan', + 'Albania', + 'Algeria', + 'Andorra', + 'Angola', + 'Antigua and Barbuda', + 'Argentina', + 'Armenia', + 'Australia', + 'Austria', + 'Azerbaijan', + 'Bahamas', + 'Bahrain', + 'Bangladesh', + 'Barbados', + 'Belarus', + 'Belgium', + 'Belize', + 'Benin', + 'Bhutan', + 'Bolivia', + 'Bosnia and Herzegovina', + 'Botswana', + 'Brazil', + 'Brunei', + 'Bulgaria', + 'Burkina Faso', + 'Burundi', + 'Cambodia', + 'Cameroon', + 'Canada', + 'Cape Verde', + 'Central African Republic', + 'Chad', + 'Chile', + 'China', + 'Colombi', + 'Comoros', + 'Congo (Brazzaville)', + 'Congo', + 'Costa Rica', + "Cote d'Ivoire", + 'Croatia', + 'Cuba', + 'Cyprus', + 'Czech Republic', + 'Denmark', + 'Djibouti', + 'Dominica', + 'Dominican Republic', + 'East Timor (Timor Timur)', + 'Ecuador', + 'Egypt', + 'El Salvador', + 'Equatorial Guinea', + 'Eritrea', + 'Estonia', + 'Ethiopia', + 'Fiji', + 'Finland', + 'France', + 'Gabon', + 'Gambia, The', + 'Georgia', + 'Germany', + 'Ghana', + 'Greece', + 'Grenada', + 'Guatemala', + 'Guinea', + 'Guinea-Bissau', + 'Guyana', + 'Haiti', + 'Honduras', + 'Hungary', + 'Iceland', + 'India', + 'Indonesia', + 'Iran', + 'Iraq', + 'Ireland', + 'Israel', + 'Italy', + 'Jamaica', + 'Japan', + 'Jordan', + 'Kazakhstan', + 'Kenya', + 'Kiribati', + 'Korea, North', + 'Korea, South', + 'Kuwait', + 'Kyrgyzstan', + 'Laos', + 'Latvia', + 'Lebanon', + 'Lesotho', + 'Liberia', + 'Libya', + 'Liechtenstein', + 'Lithuania', + 'Luxembourg', + 'Macedonia', + 'Madagascar', + 'Malawi', + 'Malaysia', + 'Maldives', + 'Mali', + 'Malta', + 'Marshall Islands', + 'Mauritania', + 'Mauritius', + 'Mexico', + 'Micronesia', + 'Moldova', + 'Monaco', + 'Mongolia', + 'Morocco', + 'Mozambique', + 'Myanmar', + 'Namibia', + 'Nauru', + 'Nepal', + 'Netherlands', + 'New Zealand', + 'Nicaragua', + 'Niger', + 'Nigeria', + 'Norway', + 'Oman', + 'Pakistan', + 'Palau', + 'Panama', + 'Papua New Guinea', + 'Paraguay', + 'Peru', + 'Philippines', + 'Poland', + 'Portugal', + 'Qatar', + 'Romania', + 'Russia', + 'Rwanda', + 'Saint Kitts and Nevis', + 'Saint Lucia', + 'Saint Vincent', + 'Samoa', + 'San Marino', + 'Sao Tome and Principe', + 'Saudi Arabia', + 'Senegal', + 'Serbia and Montenegro', + 'Seychelles', + 'Sierra Leone', + 'Singapore', + 'Slovakia', + 'Slovenia', + 'Solomon Islands', + 'Somalia', + 'South Africa', + 'Spain', + 'Sri Lanka', + 'Sudan', + 'Suriname', + 'Swaziland', + 'Sweden', + 'Switzerland', + 'Syria', + 'Taiwan', + 'Tajikistan', + 'Tanzania', + 'Thailand', + 'Togo', + 'Tonga', + 'Trinidad and Tobago', + 'Tunisia', + 'Turkey', + 'Turkmenistan', + 'Tuvalu', + 'Uganda', + 'Ukraine', + 'United Arab Emirates', + 'United Kingdom', + 'United States', + 'Uruguay', + 'Uzbekistan', + 'Vanuatu', + 'Vatican City', + 'Venezuela', + 'Vietnam', + 'Yemen', + 'Zambia', + 'Zimbabwe' +] diff --git a/26_Day_World_countries_data_visualization_2/26_day_starter/images/globe-2.jpg b/26_Day_World_countries_data_visualization_2/26_day_starter/images/globe-2.jpg new file mode 100644 index 0000000..ec8f6f4 Binary files /dev/null and b/26_Day_World_countries_data_visualization_2/26_day_starter/images/globe-2.jpg differ diff --git a/26_Day_World_countries_data_visualization_2/26_day_starter/images/map_image.jpg b/26_Day_World_countries_data_visualization_2/26_day_starter/images/map_image.jpg new file mode 100644 index 0000000..feda6a4 Binary files /dev/null and b/26_Day_World_countries_data_visualization_2/26_day_starter/images/map_image.jpg differ diff --git a/26_Day_World_countries_data_visualization_2/26_day_starter/index.html b/26_Day_World_countries_data_visualization_2/26_day_starter/index.html new file mode 100644 index 0000000..a8d26f9 --- /dev/null +++ b/26_Day_World_countries_data_visualization_2/26_day_starter/index.html @@ -0,0 +1,17 @@ + + + + + 30DaysOfJavaScript:11 Day + + + +

    30DaysOfJavaScript:11 Day

    +

    Destructuring and Spread

    + + + + + + + \ No newline at end of file diff --git a/26_Day_World_countries_data_visualization_2/26_day_starter/scripts/main.js b/26_Day_World_countries_data_visualization_2/26_day_starter/scripts/main.js new file mode 100644 index 0000000..c6045c8 --- /dev/null +++ b/26_Day_World_countries_data_visualization_2/26_day_starter/scripts/main.js @@ -0,0 +1,2 @@ +console.log(countries) +alert('Open the console and check if the countries has been loaded') \ No newline at end of file diff --git a/26_Day_World_countries_data_visualization_2/26_day_world_countries_data_visualization_2.md b/26_Day_World_countries_data_visualization_2/26_day_world_countries_data_visualization_2.md new file mode 100644 index 0000000..417333b --- /dev/null +++ b/26_Day_World_countries_data_visualization_2/26_day_world_countries_data_visualization_2.md @@ -0,0 +1,37 @@ +
    +

    30 Days Of JavaScript: World Countries Data Visualization 2

    + + + + + Twitter Follow + + +Author: +Asabeneh Yetayeh
    + January, 2020 +
    + +
    + +[<< Day 25](../25_Day_World_countries_data_visualization_1/25_day_world_countries_data_visualization_1.md) | [Day 27 >>](../27_Day_Mini_project_portfolio/27_day_mini_project_portfolio.md) + +![Thirty Days Of JavaScript](../images/banners/day_1_26.png) + +- [Day 26](#day-26) + - [Exercises](#exercises) + - [Exercise: Level 1](#exercise-level-1) + +# Day 26 + +## Exercises + +### Exercise: Level 1 + +1. Visualize the countries array as follows + +![Motivation](./../images/projects/dom_mini_project_countries_day_6.1.gif) + +🎉 CONGRATULATIONS ! 🎉 + +[<< Day 25](../25_Day_World_countries_data_visualization_1/25_day_world_countries_data_visualization_1.md) | [Day 27 >>](../27_Day_Mini_project_portfolio/27_day_mini_project_portfolio.md) diff --git a/27_Day_Mini_project_portfolio/27_day_mini_project_portfolio.md b/27_Day_Mini_project_portfolio/27_day_mini_project_portfolio.md new file mode 100644 index 0000000..1412ff3 --- /dev/null +++ b/27_Day_Mini_project_portfolio/27_day_mini_project_portfolio.md @@ -0,0 +1,37 @@ +
    +

    30 Days Of JavaScript: Portfolio

    + + + + + Twitter Follow + + +Author: +Asabeneh Yetayeh
    + January, 2020 +
    + +
    + +[<< Day 26](../26_Day_World_countries_data_visualization_2/26_day_world_countries_data_visualization_2.md) | [Day 28 >>](../28_Day_Mini_project_leaderboard/28_day_mini_project_leaderboard.md) + +![Thirty Days Of JavaScript](../images/banners/day_1_27.png) + +- [Day 27](#day-27) + - [Exercises](#exercises) + - [Exercise: Level 1](#exercise-level-1) + +# Day 27 + +## Exercises + +### Exercise: Level 1 + +1. Create the following using HTML, CSS, and JavaScript + +![Slider](./../images/projects/dom_mini_project_slider_day_7.1.gif) + +🎉 CONGRATULATIONS ! 🎉 + +[<< Day 26](../26_Day_World_countries_data_visualization_2/26_day_world_countries_data_visualization_2.md) | [Day 28 >>](../28_Day_Mini_project_leaderboard/28_day_mini_project_leaderboard.md) \ No newline at end of file diff --git a/27_Day_Mini_project_portfolio/27_day_starter/index.html b/27_Day_Mini_project_portfolio/27_day_starter/index.html new file mode 100644 index 0000000..6efcab4 --- /dev/null +++ b/27_Day_Mini_project_portfolio/27_day_starter/index.html @@ -0,0 +1,17 @@ + + + + + 30DaysOfJavaScript:11 Day + + + +

    30DaysOfJavaScript:11 Day

    +

    Destructuring and Spread

    + + + + + + + \ No newline at end of file diff --git a/27_Day_Mini_project_portfolio/27_day_starter/scripts/main.js b/27_Day_Mini_project_portfolio/27_day_starter/scripts/main.js new file mode 100644 index 0000000..e69de29 diff --git a/28_Day_Mini_project_leaderboard/28_day_mini_project_leaderboard.md b/28_Day_Mini_project_leaderboard/28_day_mini_project_leaderboard.md new file mode 100644 index 0000000..723b4e9 --- /dev/null +++ b/28_Day_Mini_project_leaderboard/28_day_mini_project_leaderboard.md @@ -0,0 +1,37 @@ +
    +

    30 Days Of JavaScript

    + + + + + Twitter Follow + + +Author: +Asabeneh Yetayeh
    + January, 2020 +
    + +
    + +[<< Day 27](../27_Day_Mini_project_portfolio/27_day_mini_project_portfolio.md) | [Day 29>>](../29_Day_Mini_project_animating_characters/29_day_mini_project_animating_characters.md) + +![Thirty Days Of JavaScript](../images/banners/day_1_28.png) + +- [Day 28](#day-28) + - [Exercises](#exercises) + - [Exercise: Level 1](#exercise-level-1) + +# Day 28 + +## Exercises + +### Exercise: Level 1 + +1. Create the following using HTML, CSS, and JavaScript + +![Slider](./../images/projects/dom_mini_project_leaderboard_day_8.1.gif) + +🎉 CONGRATULATIONS ! 🎉 + +[<< Day 27](../27_Day_Mini_project_portfolio/27_day_mini_project_portfolio.md) | [Day 29>>](../29_Day_Mini_project_animating_characters/29_day_mini_project_animating_characters.md) \ No newline at end of file diff --git a/28_Day_Mini_project_leaderboard/28_day_starter/index.html b/28_Day_Mini_project_leaderboard/28_day_starter/index.html new file mode 100644 index 0000000..6efcab4 --- /dev/null +++ b/28_Day_Mini_project_leaderboard/28_day_starter/index.html @@ -0,0 +1,17 @@ + + + + + 30DaysOfJavaScript:11 Day + + + +

    30DaysOfJavaScript:11 Day

    +

    Destructuring and Spread

    + + + + + + + \ No newline at end of file diff --git a/28_Day_Mini_project_leaderboard/28_day_starter/scripts/main.js b/28_Day_Mini_project_leaderboard/28_day_starter/scripts/main.js new file mode 100644 index 0000000..e69de29 diff --git a/29_Day_Mini_project_animating_characters/29_day_mini_project_animating_characters.md b/29_Day_Mini_project_animating_characters/29_day_mini_project_animating_characters.md new file mode 100644 index 0000000..72d4b37 --- /dev/null +++ b/29_Day_Mini_project_animating_characters/29_day_mini_project_animating_characters.md @@ -0,0 +1,44 @@ +
    +

    30 Days Of JavaScript: Animating Characters

    + + + + + Twitter Follow + + +Author: +Asabeneh Yetayeh
    + January, 2020 +
    + +
    + +[<< Day 28](../28_Day_Mini_project_animating_characters/28_day_mini_project_animating_characters.md) | [Day 30>>](../30_Day_Mini_project_final/30_day_mini_project_final.md) + +![Thirty Days Of JavaScript](../images/banners/day_1_29.png) + +- [Day 29](#day-29) + - [Exercises](#exercises) + - [Exercise: Level 1](#exercise-level-1) + - [Exercise: Level 2](#exercise-level-2) + - [Exercise: Level 3](#exercise-level-3) + +# Day 29 + +## Exercises + +### Exercise: Level 1 + +1. Create the following animation using (HTML, CSS, JS) + +![Slider](./../images/projects/dom_min_project_30DaysOfJavaScript_color_changing_day_9.1.gif) + + +### Exercise: Level 2 + +### Exercise: Level 3 + +🎉 CONGRATULATIONS ! 🎉 + +[<< Day 28](../28_Day_Mini_project_animating_characters/28_day_mini_project_animating_characters.md) | [Day 30>>](../30_Day_Mini_project_final/30_day_mini_project_final.md) \ No newline at end of file diff --git a/29_Day_Mini_project_animating_characters/29_day_starters/project_1/design/dom_min_project_30DaysOfJavaScript_color_changing_day_9.1.gif b/29_Day_Mini_project_animating_characters/29_day_starters/project_1/design/dom_min_project_30DaysOfJavaScript_color_changing_day_9.1.gif new file mode 100644 index 0000000..c8d2f2b Binary files /dev/null and b/29_Day_Mini_project_animating_characters/29_day_starters/project_1/design/dom_min_project_30DaysOfJavaScript_color_changing_day_9.1.gif differ diff --git a/29_Day_Mini_project_animating_characters/29_day_starters/project_1/index.html b/29_Day_Mini_project_animating_characters/29_day_starters/project_1/index.html new file mode 100644 index 0000000..5e0e8aa --- /dev/null +++ b/29_Day_Mini_project_animating_characters/29_day_starters/project_1/index.html @@ -0,0 +1,26 @@ + + + + + + + + + + + 30Days Of JavaScript: 29 Project 1 + + + + +
    + +
    + + + + + + \ No newline at end of file diff --git a/29_Day_Mini_project_animating_characters/29_day_starters/project_1/scripts/main.js b/29_Day_Mini_project_animating_characters/29_day_starters/project_1/scripts/main.js new file mode 100644 index 0000000..c6045c8 --- /dev/null +++ b/29_Day_Mini_project_animating_characters/29_day_starters/project_1/scripts/main.js @@ -0,0 +1,2 @@ +console.log(countries) +alert('Open the console and check if the countries has been loaded') \ No newline at end of file diff --git a/29_Day_Mini_project_animating_characters/29_day_starters/project_2/data/countries_data.js b/29_Day_Mini_project_animating_characters/29_day_starters/project_2/data/countries_data.js new file mode 100644 index 0000000..92acddd --- /dev/null +++ b/29_Day_Mini_project_animating_characters/29_day_starters/project_2/data/countries_data.js @@ -0,0 +1,2013 @@ +const countries = [ + { + name: 'Afghanistan', + capital: 'Kabul', + languages: ['Pashto', 'Uzbek', 'Turkmen'], + population: 27657145, + flag: 'https://restcountries.eu/data/afg.svg', + currency: 'Afghan afghani' + }, + { + name: 'Åland Islands', + capital: 'Mariehamn', + languages: ['Swedish'], + population: 28875, + flag: 'https://restcountries.eu/data/ala.svg', + currency: 'Euro' + }, + { + name: 'Albania', + capital: 'Tirana', + languages: ['Albanian'], + population: 2886026, + flag: 'https://restcountries.eu/data/alb.svg', + currency: 'Albanian lek' + }, + { + name: 'Algeria', + capital: 'Algiers', + languages: ['Arabic'], + population: 40400000, + flag: 'https://restcountries.eu/data/dza.svg', + currency: 'Algerian dinar' + }, + { + name: 'American Samoa', + capital: 'Pago Pago', + languages: ['English', 'Samoan'], + population: 57100, + flag: 'https://restcountries.eu/data/asm.svg', + currency: 'United State Dollar' + }, + { + name: 'Andorra', + capital: 'Andorra la Vella', + languages: ['Catalan'], + population: 78014, + flag: 'https://restcountries.eu/data/and.svg', + currency: 'Euro' + }, + { + name: 'Angola', + capital: 'Luanda', + languages: ['Portuguese'], + population: 25868000, + flag: 'https://restcountries.eu/data/ago.svg', + currency: 'Angolan kwanza' + }, + { + name: 'Anguilla', + capital: 'The Valley', + languages: ['English'], + population: 13452, + flag: 'https://restcountries.eu/data/aia.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Antarctica', + capital: '', + languages: ['English', 'Russian'], + population: 1000, + flag: 'https://restcountries.eu/data/ata.svg', + currency: 'Australian dollar' + }, + { + name: 'Antigua and Barbuda', + capital: "Saint John's", + languages: ['English'], + population: 86295, + flag: 'https://restcountries.eu/data/atg.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Argentina', + capital: 'Buenos Aires', + languages: ['Spanish', 'Guaraní'], + population: 43590400, + flag: 'https://restcountries.eu/data/arg.svg', + currency: 'Argentine peso' + }, + { + name: 'Armenia', + capital: 'Yerevan', + languages: ['Armenian', 'Russian'], + population: 2994400, + flag: 'https://restcountries.eu/data/arm.svg', + currency: 'Armenian dram' + }, + { + name: 'Aruba', + capital: 'Oranjestad', + languages: ['Dutch', '(Eastern) Punjabi'], + population: 107394, + flag: 'https://restcountries.eu/data/abw.svg', + currency: 'Aruban florin' + }, + { + name: 'Australia', + capital: 'Canberra', + languages: ['English'], + population: 24117360, + flag: 'https://restcountries.eu/data/aus.svg', + currency: 'Australian dollar' + }, + { + name: 'Austria', + capital: 'Vienna', + languages: ['German'], + population: 8725931, + flag: 'https://restcountries.eu/data/aut.svg', + currency: 'Euro' + }, + { + name: 'Azerbaijan', + capital: 'Baku', + languages: ['Azerbaijani'], + population: 9730500, + flag: 'https://restcountries.eu/data/aze.svg', + currency: 'Azerbaijani manat' + }, + { + name: 'Bahamas', + capital: 'Nassau', + languages: ['English'], + population: 378040, + flag: 'https://restcountries.eu/data/bhs.svg', + currency: 'Bahamian dollar' + }, + { + name: 'Bahrain', + capital: 'Manama', + languages: ['Arabic'], + population: 1404900, + flag: 'https://restcountries.eu/data/bhr.svg', + currency: 'Bahraini dinar' + }, + { + name: 'Bangladesh', + capital: 'Dhaka', + languages: ['Bengali'], + population: 161006790, + flag: 'https://restcountries.eu/data/bgd.svg', + currency: 'Bangladeshi taka' + }, + { + name: 'Barbados', + capital: 'Bridgetown', + languages: ['English'], + population: 285000, + flag: 'https://restcountries.eu/data/brb.svg', + currency: 'Barbadian dollar' + }, + { + name: 'Belarus', + capital: 'Minsk', + languages: ['Belarusian', 'Russian'], + population: 9498700, + flag: 'https://restcountries.eu/data/blr.svg', + currency: 'New Belarusian ruble' + }, + { + name: 'Belgium', + capital: 'Brussels', + languages: ['Dutch', 'French', 'German'], + population: 11319511, + flag: 'https://restcountries.eu/data/bel.svg', + currency: 'Euro' + }, + { + name: 'Belize', + capital: 'Belmopan', + languages: ['English', 'Spanish'], + population: 370300, + flag: 'https://restcountries.eu/data/blz.svg', + currency: 'Belize dollar' + }, + { + name: 'Benin', + capital: 'Porto-Novo', + languages: ['French'], + population: 10653654, + flag: 'https://restcountries.eu/data/ben.svg', + currency: 'West African CFA franc' + }, + { + name: 'Bermuda', + capital: 'Hamilton', + languages: ['English'], + population: 61954, + flag: 'https://restcountries.eu/data/bmu.svg', + currency: 'Bermudian dollar' + }, + { + name: 'Bhutan', + capital: 'Thimphu', + languages: ['Dzongkha'], + population: 775620, + flag: 'https://restcountries.eu/data/btn.svg', + currency: 'Bhutanese ngultrum' + }, + { + name: 'Bolivia (Plurinational State of)', + capital: 'Sucre', + languages: ['Spanish', 'Aymara', 'Quechua'], + population: 10985059, + flag: 'https://restcountries.eu/data/bol.svg', + currency: 'Bolivian boliviano' + }, + { + name: 'Bonaire, Sint Eustatius and Saba', + capital: 'Kralendijk', + languages: ['Dutch'], + population: 17408, + flag: 'https://restcountries.eu/data/bes.svg', + currency: 'United States dollar' + }, + { + name: 'Bosnia and Herzegovina', + capital: 'Sarajevo', + languages: ['Bosnian', 'Croatian', 'Serbian'], + population: 3531159, + flag: 'https://restcountries.eu/data/bih.svg', + currency: 'Bosnia and Herzegovina convertible mark' + }, + { + name: 'Botswana', + capital: 'Gaborone', + languages: ['English', 'Tswana'], + population: 2141206, + flag: 'https://restcountries.eu/data/bwa.svg', + currency: 'Botswana pula' + }, + { + name: 'Bouvet Island', + capital: '', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 0, + flag: 'https://restcountries.eu/data/bvt.svg', + currency: 'Norwegian krone' + }, + { + name: 'Brazil', + capital: 'Brasília', + languages: ['Portuguese'], + population: 206135893, + flag: 'https://restcountries.eu/data/bra.svg', + currency: 'Brazilian real' + }, + { + name: 'British Indian Ocean Territory', + capital: 'Diego Garcia', + languages: ['English'], + population: 3000, + flag: 'https://restcountries.eu/data/iot.svg', + currency: 'United States dollar' + }, + { + name: 'United States Minor Outlying Islands', + capital: '', + languages: ['English'], + population: 300, + flag: 'https://restcountries.eu/data/umi.svg', + currency: 'United States Dollar' + }, + { + name: 'Virgin Islands (British)', + capital: 'Road Town', + languages: ['English'], + population: 28514, + flag: 'https://restcountries.eu/data/vgb.svg', + currency: '[D]' + }, + { + name: 'Virgin Islands (U.S.)', + capital: 'Charlotte Amalie', + languages: ['English'], + population: 114743, + flag: 'https://restcountries.eu/data/vir.svg', + currency: 'United States dollar' + }, + { + name: 'Brunei Darussalam', + capital: 'Bandar Seri Begawan', + languages: ['Malay'], + population: 411900, + flag: 'https://restcountries.eu/data/brn.svg', + currency: 'Brunei dollar' + }, + { + name: 'Bulgaria', + capital: 'Sofia', + languages: ['Bulgarian'], + population: 7153784, + flag: 'https://restcountries.eu/data/bgr.svg', + currency: 'Bulgarian lev' + }, + { + name: 'Burkina Faso', + capital: 'Ouagadougou', + languages: ['French', 'Fula'], + population: 19034397, + flag: 'https://restcountries.eu/data/bfa.svg', + currency: 'West African CFA franc' + }, + { + name: 'Burundi', + capital: 'Bujumbura', + languages: ['French', 'Kirundi'], + population: 10114505, + flag: 'https://restcountries.eu/data/bdi.svg', + currency: 'Burundian franc' + }, + { + name: 'Cambodia', + capital: 'Phnom Penh', + languages: ['Khmer'], + population: 15626444, + flag: 'https://restcountries.eu/data/khm.svg', + currency: 'Cambodian riel' + }, + { + name: 'Cameroon', + capital: 'Yaoundé', + languages: ['English', 'French'], + population: 22709892, + flag: 'https://restcountries.eu/data/cmr.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Canada', + capital: 'Ottawa', + languages: ['English', 'French'], + population: 36155487, + flag: 'https://restcountries.eu/data/can.svg', + currency: 'Canadian dollar' + }, + { + name: 'Cabo Verde', + capital: 'Praia', + languages: ['Portuguese'], + population: 531239, + flag: 'https://restcountries.eu/data/cpv.svg', + currency: 'Cape Verdean escudo' + }, + { + name: 'Cayman Islands', + capital: 'George Town', + languages: ['English'], + population: 58238, + flag: 'https://restcountries.eu/data/cym.svg', + currency: 'Cayman Islands dollar' + }, + { + name: 'Central African Republic', + capital: 'Bangui', + languages: ['French', 'Sango'], + population: 4998000, + flag: 'https://restcountries.eu/data/caf.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chad', + capital: "N'Djamena", + languages: ['French', 'Arabic'], + population: 14497000, + flag: 'https://restcountries.eu/data/tcd.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chile', + capital: 'Santiago', + languages: ['Spanish'], + population: 18191900, + flag: 'https://restcountries.eu/data/chl.svg', + currency: 'Chilean peso' + }, + { + name: 'China', + capital: 'Beijing', + languages: ['Chinese'], + population: 1377422166, + flag: 'https://restcountries.eu/data/chn.svg', + currency: 'Chinese yuan' + }, + { + name: 'Christmas Island', + capital: 'Flying Fish Cove', + languages: ['English'], + population: 2072, + flag: 'https://restcountries.eu/data/cxr.svg', + currency: 'Australian dollar' + }, + { + name: 'Cocos (Keeling) Islands', + capital: 'West Island', + languages: ['English'], + population: 550, + flag: 'https://restcountries.eu/data/cck.svg', + currency: 'Australian dollar' + }, + { + name: 'Colombia', + capital: 'Bogotá', + languages: ['Spanish'], + population: 48759958, + flag: 'https://restcountries.eu/data/col.svg', + currency: 'Colombian peso' + }, + { + name: 'Comoros', + capital: 'Moroni', + languages: ['Arabic', 'French'], + population: 806153, + flag: 'https://restcountries.eu/data/com.svg', + currency: 'Comorian franc' + }, + { + name: 'Congo', + capital: 'Brazzaville', + languages: ['French', 'Lingala'], + population: 4741000, + flag: 'https://restcountries.eu/data/cog.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Congo (Democratic Republic of the)', + capital: 'Kinshasa', + languages: ['French', 'Lingala', 'Kongo', 'Swahili', 'Luba-Katanga'], + population: 85026000, + flag: 'https://restcountries.eu/data/cod.svg', + currency: 'Congolese franc' + }, + { + name: 'Cook Islands', + capital: 'Avarua', + languages: ['English'], + population: 18100, + flag: 'https://restcountries.eu/data/cok.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Costa Rica', + capital: 'San José', + languages: ['Spanish'], + population: 4890379, + flag: 'https://restcountries.eu/data/cri.svg', + currency: 'Costa Rican colón' + }, + { + name: 'Croatia', + capital: 'Zagreb', + languages: ['Croatian'], + population: 4190669, + flag: 'https://restcountries.eu/data/hrv.svg', + currency: 'Croatian kuna' + }, + { + name: 'Cuba', + capital: 'Havana', + languages: ['Spanish'], + population: 11239004, + flag: 'https://restcountries.eu/data/cub.svg', + currency: 'Cuban convertible peso' + }, + { + name: 'Curaçao', + capital: 'Willemstad', + languages: ['Dutch', '(Eastern) Punjabi', 'English'], + population: 154843, + flag: 'https://restcountries.eu/data/cuw.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Cyprus', + capital: 'Nicosia', + languages: ['Greek (modern)', 'Turkish', 'Armenian'], + population: 847000, + flag: 'https://restcountries.eu/data/cyp.svg', + currency: 'Euro' + }, + { + name: 'Czech Republic', + capital: 'Prague', + languages: ['Czech', 'Slovak'], + population: 10558524, + flag: 'https://restcountries.eu/data/cze.svg', + currency: 'Czech koruna' + }, + { + name: 'Denmark', + capital: 'Copenhagen', + languages: ['Danish'], + population: 5717014, + flag: 'https://restcountries.eu/data/dnk.svg', + currency: 'Danish krone' + }, + { + name: 'Djibouti', + capital: 'Djibouti', + languages: ['French', 'Arabic'], + population: 900000, + flag: 'https://restcountries.eu/data/dji.svg', + currency: 'Djiboutian franc' + }, + { + name: 'Dominica', + capital: 'Roseau', + languages: ['English'], + population: 71293, + flag: 'https://restcountries.eu/data/dma.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Dominican Republic', + capital: 'Santo Domingo', + languages: ['Spanish'], + population: 10075045, + flag: 'https://restcountries.eu/data/dom.svg', + currency: 'Dominican peso' + }, + { + name: 'Ecuador', + capital: 'Quito', + languages: ['Spanish'], + population: 16545799, + flag: 'https://restcountries.eu/data/ecu.svg', + currency: 'United States dollar' + }, + { + name: 'Egypt', + capital: 'Cairo', + languages: ['Arabic'], + population: 91290000, + flag: 'https://restcountries.eu/data/egy.svg', + currency: 'Egyptian pound' + }, + { + name: 'El Salvador', + capital: 'San Salvador', + languages: ['Spanish'], + population: 6520675, + flag: 'https://restcountries.eu/data/slv.svg', + currency: 'United States dollar' + }, + { + name: 'Equatorial Guinea', + capital: 'Malabo', + languages: ['Spanish', 'French'], + population: 1222442, + flag: 'https://restcountries.eu/data/gnq.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Eritrea', + capital: 'Asmara', + languages: ['Tigrinya', 'Arabic', 'English'], + population: 5352000, + flag: 'https://restcountries.eu/data/eri.svg', + currency: 'Eritrean nakfa' + }, + { + name: 'Estonia', + capital: 'Tallinn', + languages: ['Estonian'], + population: 1315944, + flag: 'https://restcountries.eu/data/est.svg', + currency: 'Euro' + }, + { + name: 'Ethiopia', + capital: 'Addis Ababa', + languages: ['Amharic'], + population: 92206005, + flag: 'https://restcountries.eu/data/eth.svg', + currency: 'Ethiopian birr' + }, + { + name: 'Falkland Islands (Malvinas)', + capital: 'Stanley', + languages: ['English'], + population: 2563, + flag: 'https://restcountries.eu/data/flk.svg', + currency: 'Falkland Islands pound' + }, + { + name: 'Faroe Islands', + capital: 'Tórshavn', + languages: ['Faroese'], + population: 49376, + flag: 'https://restcountries.eu/data/fro.svg', + currency: 'Danish krone' + }, + { + name: 'Fiji', + capital: 'Suva', + languages: ['English', 'Fijian', 'Hindi', 'Urdu'], + population: 867000, + flag: 'https://restcountries.eu/data/fji.svg', + currency: 'Fijian dollar' + }, + { + name: 'Finland', + capital: 'Helsinki', + languages: ['Finnish', 'Swedish'], + population: 5491817, + flag: 'https://restcountries.eu/data/fin.svg', + currency: 'Euro' + }, + { + name: 'France', + capital: 'Paris', + languages: ['French'], + population: 66710000, + flag: 'https://restcountries.eu/data/fra.svg', + currency: 'Euro' + }, + { + name: 'French Guiana', + capital: 'Cayenne', + languages: ['French'], + population: 254541, + flag: 'https://restcountries.eu/data/guf.svg', + currency: 'Euro' + }, + { + name: 'French Polynesia', + capital: 'Papeetē', + languages: ['French'], + population: 271800, + flag: 'https://restcountries.eu/data/pyf.svg', + currency: 'CFP franc' + }, + { + name: 'French Southern Territories', + capital: 'Port-aux-Français', + languages: ['French'], + population: 140, + flag: 'https://restcountries.eu/data/atf.svg', + currency: 'Euro' + }, + { + name: 'Gabon', + capital: 'Libreville', + languages: ['French'], + population: 1802278, + flag: 'https://restcountries.eu/data/gab.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Gambia', + capital: 'Banjul', + languages: ['English'], + population: 1882450, + flag: 'https://restcountries.eu/data/gmb.svg', + currency: 'Gambian dalasi' + }, + { + name: 'Georgia', + capital: 'Tbilisi', + languages: ['Georgian'], + population: 3720400, + flag: 'https://restcountries.eu/data/geo.svg', + currency: 'Georgian Lari' + }, + { + name: 'Germany', + capital: 'Berlin', + languages: ['German'], + population: 81770900, + flag: 'https://restcountries.eu/data/deu.svg', + currency: 'Euro' + }, + { + name: 'Ghana', + capital: 'Accra', + languages: ['English'], + population: 27670174, + flag: 'https://restcountries.eu/data/gha.svg', + currency: 'Ghanaian cedi' + }, + { + name: 'Gibraltar', + capital: 'Gibraltar', + languages: ['English'], + population: 33140, + flag: 'https://restcountries.eu/data/gib.svg', + currency: 'Gibraltar pound' + }, + { + name: 'Greece', + capital: 'Athens', + languages: ['Greek (modern)'], + population: 10858018, + flag: 'https://restcountries.eu/data/grc.svg', + currency: 'Euro' + }, + { + name: 'Greenland', + capital: 'Nuuk', + languages: ['Kalaallisut'], + population: 55847, + flag: 'https://restcountries.eu/data/grl.svg', + currency: 'Danish krone' + }, + { + name: 'Grenada', + capital: "St. George's", + languages: ['English'], + population: 103328, + flag: 'https://restcountries.eu/data/grd.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Guadeloupe', + capital: 'Basse-Terre', + languages: ['French'], + population: 400132, + flag: 'https://restcountries.eu/data/glp.svg', + currency: 'Euro' + }, + { + name: 'Guam', + capital: 'Hagåtña', + languages: ['English', 'Chamorro', 'Spanish'], + population: 184200, + flag: 'https://restcountries.eu/data/gum.svg', + currency: 'United States dollar' + }, + { + name: 'Guatemala', + capital: 'Guatemala City', + languages: ['Spanish'], + population: 16176133, + flag: 'https://restcountries.eu/data/gtm.svg', + currency: 'Guatemalan quetzal' + }, + { + name: 'Guernsey', + capital: 'St. Peter Port', + languages: ['English', 'French'], + population: 62999, + flag: 'https://restcountries.eu/data/ggy.svg', + currency: 'British pound' + }, + { + name: 'Guinea', + capital: 'Conakry', + languages: ['French', 'Fula'], + population: 12947000, + flag: 'https://restcountries.eu/data/gin.svg', + currency: 'Guinean franc' + }, + { + name: 'Guinea-Bissau', + capital: 'Bissau', + languages: ['Portuguese'], + population: 1547777, + flag: 'https://restcountries.eu/data/gnb.svg', + currency: 'West African CFA franc' + }, + { + name: 'Guyana', + capital: 'Georgetown', + languages: ['English'], + population: 746900, + flag: 'https://restcountries.eu/data/guy.svg', + currency: 'Guyanese dollar' + }, + { + name: 'Haiti', + capital: 'Port-au-Prince', + languages: ['French', 'Haitian'], + population: 11078033, + flag: 'https://restcountries.eu/data/hti.svg', + currency: 'Haitian gourde' + }, + { + name: 'Heard Island and McDonald Islands', + capital: '', + languages: ['English'], + population: 0, + flag: 'https://restcountries.eu/data/hmd.svg', + currency: 'Australian dollar' + }, + { + name: 'Holy See', + capital: 'Rome', + languages: ['Latin', 'Italian', 'French', 'German'], + population: 451, + flag: 'https://restcountries.eu/data/vat.svg', + currency: 'Euro' + }, + { + name: 'Honduras', + capital: 'Tegucigalpa', + languages: ['Spanish'], + population: 8576532, + flag: 'https://restcountries.eu/data/hnd.svg', + currency: 'Honduran lempira' + }, + { + name: 'Hong Kong', + capital: 'City of Victoria', + languages: ['English', 'Chinese'], + population: 7324300, + flag: 'https://restcountries.eu/data/hkg.svg', + currency: 'Hong Kong dollar' + }, + { + name: 'Hungary', + capital: 'Budapest', + languages: ['Hungarian'], + population: 9823000, + flag: 'https://restcountries.eu/data/hun.svg', + currency: 'Hungarian forint' + }, + { + name: 'Iceland', + capital: 'Reykjavík', + languages: ['Icelandic'], + population: 334300, + flag: 'https://restcountries.eu/data/isl.svg', + currency: 'Icelandic króna' + }, + { + name: 'India', + capital: 'New Delhi', + languages: ['Hindi', 'English'], + population: 1295210000, + flag: 'https://restcountries.eu/data/ind.svg', + currency: 'Indian rupee' + }, + { + name: 'Indonesia', + capital: 'Jakarta', + languages: ['Indonesian'], + population: 258705000, + flag: 'https://restcountries.eu/data/idn.svg', + currency: 'Indonesian rupiah' + }, + { + name: "Côte d'Ivoire", + capital: 'Yamoussoukro', + languages: ['French'], + population: 22671331, + flag: 'https://restcountries.eu/data/civ.svg', + currency: 'West African CFA franc' + }, + { + name: 'Iran (Islamic Republic of)', + capital: 'Tehran', + languages: ['Persian (Farsi)'], + population: 79369900, + flag: 'https://restcountries.eu/data/irn.svg', + currency: 'Iranian rial' + }, + { + name: 'Iraq', + capital: 'Baghdad', + languages: ['Arabic', 'Kurdish'], + population: 37883543, + flag: 'https://restcountries.eu/data/irq.svg', + currency: 'Iraqi dinar' + }, + { + name: 'Ireland', + capital: 'Dublin', + languages: ['Irish', 'English'], + population: 6378000, + flag: 'https://restcountries.eu/data/irl.svg', + currency: 'Euro' + }, + { + name: 'Isle of Man', + capital: 'Douglas', + languages: ['English', 'Manx'], + population: 84497, + flag: 'https://restcountries.eu/data/imn.svg', + currency: 'British pound' + }, + { + name: 'Israel', + capital: 'Jerusalem', + languages: ['Hebrew (modern)', 'Arabic'], + population: 8527400, + flag: 'https://restcountries.eu/data/isr.svg', + currency: 'Israeli new shekel' + }, + { + name: 'Italy', + capital: 'Rome', + languages: ['Italian'], + population: 60665551, + flag: 'https://restcountries.eu/data/ita.svg', + currency: 'Euro' + }, + { + name: 'Jamaica', + capital: 'Kingston', + languages: ['English'], + population: 2723246, + flag: 'https://restcountries.eu/data/jam.svg', + currency: 'Jamaican dollar' + }, + { + name: 'Japan', + capital: 'Tokyo', + languages: ['Japanese'], + population: 126960000, + flag: 'https://restcountries.eu/data/jpn.svg', + currency: 'Japanese yen' + }, + { + name: 'Jersey', + capital: 'Saint Helier', + languages: ['English', 'French'], + population: 100800, + flag: 'https://restcountries.eu/data/jey.svg', + currency: 'British pound' + }, + { + name: 'Jordan', + capital: 'Amman', + languages: ['Arabic'], + population: 9531712, + flag: 'https://restcountries.eu/data/jor.svg', + currency: 'Jordanian dinar' + }, + { + name: 'Kazakhstan', + capital: 'Astana', + languages: ['Kazakh', 'Russian'], + population: 17753200, + flag: 'https://restcountries.eu/data/kaz.svg', + currency: 'Kazakhstani tenge' + }, + { + name: 'Kenya', + capital: 'Nairobi', + languages: ['English', 'Swahili'], + population: 47251000, + flag: 'https://restcountries.eu/data/ken.svg', + currency: 'Kenyan shilling' + }, + { + name: 'Kiribati', + capital: 'South Tarawa', + languages: ['English'], + population: 113400, + flag: 'https://restcountries.eu/data/kir.svg', + currency: 'Australian dollar' + }, + { + name: 'Kuwait', + capital: 'Kuwait City', + languages: ['Arabic'], + population: 4183658, + flag: 'https://restcountries.eu/data/kwt.svg', + currency: 'Kuwaiti dinar' + }, + { + name: 'Kyrgyzstan', + capital: 'Bishkek', + languages: ['Kyrgyz', 'Russian'], + population: 6047800, + flag: 'https://restcountries.eu/data/kgz.svg', + currency: 'Kyrgyzstani som' + }, + { + name: "Lao People's Democratic Republic", + capital: 'Vientiane', + languages: ['Lao'], + population: 6492400, + flag: 'https://restcountries.eu/data/lao.svg', + currency: 'Lao kip' + }, + { + name: 'Latvia', + capital: 'Riga', + languages: ['Latvian'], + population: 1961600, + flag: 'https://restcountries.eu/data/lva.svg', + currency: 'Euro' + }, + { + name: 'Lebanon', + capital: 'Beirut', + languages: ['Arabic', 'French'], + population: 5988000, + flag: 'https://restcountries.eu/data/lbn.svg', + currency: 'Lebanese pound' + }, + { + name: 'Lesotho', + capital: 'Maseru', + languages: ['English', 'Southern Sotho'], + population: 1894194, + flag: 'https://restcountries.eu/data/lso.svg', + currency: 'Lesotho loti' + }, + { + name: 'Liberia', + capital: 'Monrovia', + languages: ['English'], + population: 4615000, + flag: 'https://restcountries.eu/data/lbr.svg', + currency: 'Liberian dollar' + }, + { + name: 'Libya', + capital: 'Tripoli', + languages: ['Arabic'], + population: 6385000, + flag: 'https://restcountries.eu/data/lby.svg', + currency: 'Libyan dinar' + }, + { + name: 'Liechtenstein', + capital: 'Vaduz', + languages: ['German'], + population: 37623, + flag: 'https://restcountries.eu/data/lie.svg', + currency: 'Swiss franc' + }, + { + name: 'Lithuania', + capital: 'Vilnius', + languages: ['Lithuanian'], + population: 2872294, + flag: 'https://restcountries.eu/data/ltu.svg', + currency: 'Euro' + }, + { + name: 'Luxembourg', + capital: 'Luxembourg', + languages: ['French', 'German', 'Luxembourgish'], + population: 576200, + flag: 'https://restcountries.eu/data/lux.svg', + currency: 'Euro' + }, + { + name: 'Macao', + capital: '', + languages: ['Chinese', 'Portuguese'], + population: 649100, + flag: 'https://restcountries.eu/data/mac.svg', + currency: 'Macanese pataca' + }, + { + name: 'Macedonia (the former Yugoslav Republic of)', + capital: 'Skopje', + languages: ['Macedonian'], + population: 2058539, + flag: 'https://restcountries.eu/data/mkd.svg', + currency: 'Macedonian denar' + }, + { + name: 'Madagascar', + capital: 'Antananarivo', + languages: ['French', 'Malagasy'], + population: 22434363, + flag: 'https://restcountries.eu/data/mdg.svg', + currency: 'Malagasy ariary' + }, + { + name: 'Malawi', + capital: 'Lilongwe', + languages: ['English', 'Chichewa'], + population: 16832910, + flag: 'https://restcountries.eu/data/mwi.svg', + currency: 'Malawian kwacha' + }, + { + name: 'Malaysia', + capital: 'Kuala Lumpur', + languages: ['Malaysian'], + population: 31405416, + flag: 'https://restcountries.eu/data/mys.svg', + currency: 'Malaysian ringgit' + }, + { + name: 'Maldives', + capital: 'Malé', + languages: ['Divehi'], + population: 344023, + flag: 'https://restcountries.eu/data/mdv.svg', + currency: 'Maldivian rufiyaa' + }, + { + name: 'Mali', + capital: 'Bamako', + languages: ['French'], + population: 18135000, + flag: 'https://restcountries.eu/data/mli.svg', + currency: 'West African CFA franc' + }, + { + name: 'Malta', + capital: 'Valletta', + languages: ['Maltese', 'English'], + population: 425384, + flag: 'https://restcountries.eu/data/mlt.svg', + currency: 'Euro' + }, + { + name: 'Marshall Islands', + capital: 'Majuro', + languages: ['English', 'Marshallese'], + population: 54880, + flag: 'https://restcountries.eu/data/mhl.svg', + currency: 'United States dollar' + }, + { + name: 'Martinique', + capital: 'Fort-de-France', + languages: ['French'], + population: 378243, + flag: 'https://restcountries.eu/data/mtq.svg', + currency: 'Euro' + }, + { + name: 'Mauritania', + capital: 'Nouakchott', + languages: ['Arabic'], + population: 3718678, + flag: 'https://restcountries.eu/data/mrt.svg', + currency: 'Mauritanian ouguiya' + }, + { + name: 'Mauritius', + capital: 'Port Louis', + languages: ['English'], + population: 1262879, + flag: 'https://restcountries.eu/data/mus.svg', + currency: 'Mauritian rupee' + }, + { + name: 'Mayotte', + capital: 'Mamoudzou', + languages: ['French'], + population: 226915, + flag: 'https://restcountries.eu/data/myt.svg', + currency: 'Euro' + }, + { + name: 'Mexico', + capital: 'Mexico City', + languages: ['Spanish'], + population: 122273473, + flag: 'https://restcountries.eu/data/mex.svg', + currency: 'Mexican peso' + }, + { + name: 'Micronesia (Federated States of)', + capital: 'Palikir', + languages: ['English'], + population: 102800, + flag: 'https://restcountries.eu/data/fsm.svg', + currency: '[D]' + }, + { + name: 'Moldova (Republic of)', + capital: 'Chișinău', + languages: ['Romanian'], + population: 3553100, + flag: 'https://restcountries.eu/data/mda.svg', + currency: 'Moldovan leu' + }, + { + name: 'Monaco', + capital: 'Monaco', + languages: ['French'], + population: 38400, + flag: 'https://restcountries.eu/data/mco.svg', + currency: 'Euro' + }, + { + name: 'Mongolia', + capital: 'Ulan Bator', + languages: ['Mongolian'], + population: 3093100, + flag: 'https://restcountries.eu/data/mng.svg', + currency: 'Mongolian tögrög' + }, + { + name: 'Montenegro', + capital: 'Podgorica', + languages: ['Serbian', 'Bosnian', 'Albanian', 'Croatian'], + population: 621810, + flag: 'https://restcountries.eu/data/mne.svg', + currency: 'Euro' + }, + { + name: 'Montserrat', + capital: 'Plymouth', + languages: ['English'], + population: 4922, + flag: 'https://restcountries.eu/data/msr.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Morocco', + capital: 'Rabat', + languages: ['Arabic'], + population: 33337529, + flag: 'https://restcountries.eu/data/mar.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Mozambique', + capital: 'Maputo', + languages: ['Portuguese'], + population: 26423700, + flag: 'https://restcountries.eu/data/moz.svg', + currency: 'Mozambican metical' + }, + { + name: 'Myanmar', + capital: 'Naypyidaw', + languages: ['Burmese'], + population: 51419420, + flag: 'https://restcountries.eu/data/mmr.svg', + currency: 'Burmese kyat' + }, + { + name: 'Namibia', + capital: 'Windhoek', + languages: ['English', 'Afrikaans'], + population: 2324388, + flag: 'https://restcountries.eu/data/nam.svg', + currency: 'Namibian dollar' + }, + { + name: 'Nauru', + capital: 'Yaren', + languages: ['English', 'Nauruan'], + population: 10084, + flag: 'https://restcountries.eu/data/nru.svg', + currency: 'Australian dollar' + }, + { + name: 'Nepal', + capital: 'Kathmandu', + languages: ['Nepali'], + population: 28431500, + flag: 'https://restcountries.eu/data/npl.svg', + currency: 'Nepalese rupee' + }, + { + name: 'Netherlands', + capital: 'Amsterdam', + languages: ['Dutch'], + population: 17019800, + flag: 'https://restcountries.eu/data/nld.svg', + currency: 'Euro' + }, + { + name: 'New Caledonia', + capital: 'Nouméa', + languages: ['French'], + population: 268767, + flag: 'https://restcountries.eu/data/ncl.svg', + currency: 'CFP franc' + }, + { + name: 'New Zealand', + capital: 'Wellington', + languages: ['English', 'Māori'], + population: 4697854, + flag: 'https://restcountries.eu/data/nzl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Nicaragua', + capital: 'Managua', + languages: ['Spanish'], + population: 6262703, + flag: 'https://restcountries.eu/data/nic.svg', + currency: 'Nicaraguan córdoba' + }, + { + name: 'Niger', + capital: 'Niamey', + languages: ['French'], + population: 20715000, + flag: 'https://restcountries.eu/data/ner.svg', + currency: 'West African CFA franc' + }, + { + name: 'Nigeria', + capital: 'Abuja', + languages: ['English'], + population: 186988000, + flag: 'https://restcountries.eu/data/nga.svg', + currency: 'Nigerian naira' + }, + { + name: 'Niue', + capital: 'Alofi', + languages: ['English'], + population: 1470, + flag: 'https://restcountries.eu/data/niu.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Norfolk Island', + capital: 'Kingston', + languages: ['English'], + population: 2302, + flag: 'https://restcountries.eu/data/nfk.svg', + currency: 'Australian dollar' + }, + { + name: "Korea (Democratic People's Republic of)", + capital: 'Pyongyang', + languages: ['Korean'], + population: 25281000, + flag: 'https://restcountries.eu/data/prk.svg', + currency: 'North Korean won' + }, + { + name: 'Northern Mariana Islands', + capital: 'Saipan', + languages: ['English', 'Chamorro'], + population: 56940, + flag: 'https://restcountries.eu/data/mnp.svg', + currency: 'United States dollar' + }, + { + name: 'Norway', + capital: 'Oslo', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 5223256, + flag: 'https://restcountries.eu/data/nor.svg', + currency: 'Norwegian krone' + }, + { + name: 'Oman', + capital: 'Muscat', + languages: ['Arabic'], + population: 4420133, + flag: 'https://restcountries.eu/data/omn.svg', + currency: 'Omani rial' + }, + { + name: 'Pakistan', + capital: 'Islamabad', + languages: ['English', 'Urdu'], + population: 194125062, + flag: 'https://restcountries.eu/data/pak.svg', + currency: 'Pakistani rupee' + }, + { + name: 'Palau', + capital: 'Ngerulmud', + languages: ['English'], + population: 17950, + flag: 'https://restcountries.eu/data/plw.svg', + currency: '[E]' + }, + { + name: 'Palestine, State of', + capital: 'Ramallah', + languages: ['Arabic'], + population: 4682467, + flag: 'https://restcountries.eu/data/pse.svg', + currency: 'Israeli new sheqel' + }, + { + name: 'Panama', + capital: 'Panama City', + languages: ['Spanish'], + population: 3814672, + flag: 'https://restcountries.eu/data/pan.svg', + currency: 'Panamanian balboa' + }, + { + name: 'Papua New Guinea', + capital: 'Port Moresby', + languages: ['English'], + population: 8083700, + flag: 'https://restcountries.eu/data/png.svg', + currency: 'Papua New Guinean kina' + }, + { + name: 'Paraguay', + capital: 'Asunción', + languages: ['Spanish', 'Guaraní'], + population: 6854536, + flag: 'https://restcountries.eu/data/pry.svg', + currency: 'Paraguayan guaraní' + }, + { + name: 'Peru', + capital: 'Lima', + languages: ['Spanish'], + population: 31488700, + flag: 'https://restcountries.eu/data/per.svg', + currency: 'Peruvian sol' + }, + { + name: 'Philippines', + capital: 'Manila', + languages: ['English'], + population: 103279800, + flag: 'https://restcountries.eu/data/phl.svg', + currency: 'Philippine peso' + }, + { + name: 'Pitcairn', + capital: 'Adamstown', + languages: ['English'], + population: 56, + flag: 'https://restcountries.eu/data/pcn.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Poland', + capital: 'Warsaw', + languages: ['Polish'], + population: 38437239, + flag: 'https://restcountries.eu/data/pol.svg', + currency: 'Polish złoty' + }, + { + name: 'Portugal', + capital: 'Lisbon', + languages: ['Portuguese'], + population: 10374822, + flag: 'https://restcountries.eu/data/prt.svg', + currency: 'Euro' + }, + { + name: 'Puerto Rico', + capital: 'San Juan', + languages: ['Spanish', 'English'], + population: 3474182, + flag: 'https://restcountries.eu/data/pri.svg', + currency: 'United States dollar' + }, + { + name: 'Qatar', + capital: 'Doha', + languages: ['Arabic'], + population: 2587564, + flag: 'https://restcountries.eu/data/qat.svg', + currency: 'Qatari riyal' + }, + { + name: 'Republic of Kosovo', + capital: 'Pristina', + languages: ['Albanian', 'Serbian'], + population: 1733842, + flag: 'https://restcountries.eu/data/kos.svg', + currency: 'Euro' + }, + { + name: 'Réunion', + capital: 'Saint-Denis', + languages: ['French'], + population: 840974, + flag: 'https://restcountries.eu/data/reu.svg', + currency: 'Euro' + }, + { + name: 'Romania', + capital: 'Bucharest', + languages: ['Romanian'], + population: 19861408, + flag: 'https://restcountries.eu/data/rou.svg', + currency: 'Romanian leu' + }, + { + name: 'Russian Federation', + capital: 'Moscow', + languages: ['Russian'], + population: 146599183, + flag: 'https://restcountries.eu/data/rus.svg', + currency: 'Russian ruble' + }, + { + name: 'Rwanda', + capital: 'Kigali', + languages: ['Kinyarwanda', 'English', 'French'], + population: 11553188, + flag: 'https://restcountries.eu/data/rwa.svg', + currency: 'Rwandan franc' + }, + { + name: 'Saint Barthélemy', + capital: 'Gustavia', + languages: ['French'], + population: 9417, + flag: 'https://restcountries.eu/data/blm.svg', + currency: 'Euro' + }, + { + name: 'Saint Helena, Ascension and Tristan da Cunha', + capital: 'Jamestown', + languages: ['English'], + population: 4255, + flag: 'https://restcountries.eu/data/shn.svg', + currency: 'Saint Helena pound' + }, + { + name: 'Saint Kitts and Nevis', + capital: 'Basseterre', + languages: ['English'], + population: 46204, + flag: 'https://restcountries.eu/data/kna.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Lucia', + capital: 'Castries', + languages: ['English'], + population: 186000, + flag: 'https://restcountries.eu/data/lca.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Martin (French part)', + capital: 'Marigot', + languages: ['English', 'French', 'Dutch'], + population: 36979, + flag: 'https://restcountries.eu/data/maf.svg', + currency: 'Euro' + }, + { + name: 'Saint Pierre and Miquelon', + capital: 'Saint-Pierre', + languages: ['French'], + population: 6069, + flag: 'https://restcountries.eu/data/spm.svg', + currency: 'Euro' + }, + { + name: 'Saint Vincent and the Grenadines', + capital: 'Kingstown', + languages: ['English'], + population: 109991, + flag: 'https://restcountries.eu/data/vct.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Samoa', + capital: 'Apia', + languages: ['Samoan', 'English'], + population: 194899, + flag: 'https://restcountries.eu/data/wsm.svg', + currency: 'Samoan tālā' + }, + { + name: 'San Marino', + capital: 'City of San Marino', + languages: ['Italian'], + population: 33005, + flag: 'https://restcountries.eu/data/smr.svg', + currency: 'Euro' + }, + { + name: 'Sao Tome and Principe', + capital: 'São Tomé', + languages: ['Portuguese'], + population: 187356, + flag: 'https://restcountries.eu/data/stp.svg', + currency: 'São Tomé and Príncipe dobra' + }, + { + name: 'Saudi Arabia', + capital: 'Riyadh', + languages: ['Arabic'], + population: 32248200, + flag: 'https://restcountries.eu/data/sau.svg', + currency: 'Saudi riyal' + }, + { + name: 'Senegal', + capital: 'Dakar', + languages: ['French'], + population: 14799859, + flag: 'https://restcountries.eu/data/sen.svg', + currency: 'West African CFA franc' + }, + { + name: 'Serbia', + capital: 'Belgrade', + languages: ['Serbian'], + population: 7076372, + flag: 'https://restcountries.eu/data/srb.svg', + currency: 'Serbian dinar' + }, + { + name: 'Seychelles', + capital: 'Victoria', + languages: ['French', 'English'], + population: 91400, + flag: 'https://restcountries.eu/data/syc.svg', + currency: 'Seychellois rupee' + }, + { + name: 'Sierra Leone', + capital: 'Freetown', + languages: ['English'], + population: 7075641, + flag: 'https://restcountries.eu/data/sle.svg', + currency: 'Sierra Leonean leone' + }, + { + name: 'Singapore', + capital: 'Singapore', + languages: ['English', 'Malay', 'Tamil', 'Chinese'], + population: 5535000, + flag: 'https://restcountries.eu/data/sgp.svg', + currency: 'Brunei dollar' + }, + { + name: 'Sint Maarten (Dutch part)', + capital: 'Philipsburg', + languages: ['Dutch', 'English'], + population: 38247, + flag: 'https://restcountries.eu/data/sxm.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Slovakia', + capital: 'Bratislava', + languages: ['Slovak'], + population: 5426252, + flag: 'https://restcountries.eu/data/svk.svg', + currency: 'Euro' + }, + { + name: 'Slovenia', + capital: 'Ljubljana', + languages: ['Slovene'], + population: 2064188, + flag: 'https://restcountries.eu/data/svn.svg', + currency: 'Euro' + }, + { + name: 'Solomon Islands', + capital: 'Honiara', + languages: ['English'], + population: 642000, + flag: 'https://restcountries.eu/data/slb.svg', + currency: 'Solomon Islands dollar' + }, + { + name: 'Somalia', + capital: 'Mogadishu', + languages: ['Somali', 'Arabic'], + population: 11079000, + flag: 'https://restcountries.eu/data/som.svg', + currency: 'Somali shilling' + }, + { + name: 'South Africa', + capital: 'Pretoria', + languages: [ + 'Afrikaans', + 'English', + 'Southern Ndebele', + 'Southern Sotho', + 'Swati', + 'Tswana', + 'Tsonga', + 'Venda', + 'Xhosa', + 'Zulu' + ], + population: 55653654, + flag: 'https://restcountries.eu/data/zaf.svg', + currency: 'South African rand' + }, + { + name: 'South Georgia and the South Sandwich Islands', + capital: 'King Edward Point', + languages: ['English'], + population: 30, + flag: 'https://restcountries.eu/data/sgs.svg', + currency: 'British pound' + }, + { + name: 'Korea (Republic of)', + capital: 'Seoul', + languages: ['Korean'], + population: 50801405, + flag: 'https://restcountries.eu/data/kor.svg', + currency: 'South Korean won' + }, + { + name: 'South Sudan', + capital: 'Juba', + languages: ['English'], + population: 12131000, + flag: 'https://restcountries.eu/data/ssd.svg', + currency: 'South Sudanese pound' + }, + { + name: 'Spain', + capital: 'Madrid', + languages: ['Spanish'], + population: 46438422, + flag: 'https://restcountries.eu/data/esp.svg', + currency: 'Euro' + }, + { + name: 'Sri Lanka', + capital: 'Colombo', + languages: ['Sinhalese', 'Tamil'], + population: 20966000, + flag: 'https://restcountries.eu/data/lka.svg', + currency: 'Sri Lankan rupee' + }, + { + name: 'Sudan', + capital: 'Khartoum', + languages: ['Arabic', 'English'], + population: 39598700, + flag: 'https://restcountries.eu/data/sdn.svg', + currency: 'Sudanese pound' + }, + { + name: 'Suriname', + capital: 'Paramaribo', + languages: ['Dutch'], + population: 541638, + flag: 'https://restcountries.eu/data/sur.svg', + currency: 'Surinamese dollar' + }, + { + name: 'Svalbard and Jan Mayen', + capital: 'Longyearbyen', + languages: ['Norwegian'], + population: 2562, + flag: 'https://restcountries.eu/data/sjm.svg', + currency: 'Norwegian krone' + }, + { + name: 'Swaziland', + capital: 'Lobamba', + languages: ['English', 'Swati'], + population: 1132657, + flag: 'https://restcountries.eu/data/swz.svg', + currency: 'Swazi lilangeni' + }, + { + name: 'Sweden', + capital: 'Stockholm', + languages: ['Swedish'], + population: 9894888, + flag: 'https://restcountries.eu/data/swe.svg', + currency: 'Swedish krona' + }, + { + name: 'Switzerland', + capital: 'Bern', + languages: ['German', 'French', 'Italian'], + population: 8341600, + flag: 'https://restcountries.eu/data/che.svg', + currency: 'Swiss franc' + }, + { + name: 'Syrian Arab Republic', + capital: 'Damascus', + languages: ['Arabic'], + population: 18564000, + flag: 'https://restcountries.eu/data/syr.svg', + currency: 'Syrian pound' + }, + { + name: 'Taiwan', + capital: 'Taipei', + languages: ['Chinese'], + population: 23503349, + flag: 'https://restcountries.eu/data/twn.svg', + currency: 'New Taiwan dollar' + }, + { + name: 'Tajikistan', + capital: 'Dushanbe', + languages: ['Tajik', 'Russian'], + population: 8593600, + flag: 'https://restcountries.eu/data/tjk.svg', + currency: 'Tajikistani somoni' + }, + { + name: 'Tanzania, United Republic of', + capital: 'Dodoma', + languages: ['Swahili', 'English'], + population: 55155000, + flag: 'https://restcountries.eu/data/tza.svg', + currency: 'Tanzanian shilling' + }, + { + name: 'Thailand', + capital: 'Bangkok', + languages: ['Thai'], + population: 65327652, + flag: 'https://restcountries.eu/data/tha.svg', + currency: 'Thai baht' + }, + { + name: 'Timor-Leste', + capital: 'Dili', + languages: ['Portuguese'], + population: 1167242, + flag: 'https://restcountries.eu/data/tls.svg', + currency: 'United States dollar' + }, + { + name: 'Togo', + capital: 'Lomé', + languages: ['French'], + population: 7143000, + flag: 'https://restcountries.eu/data/tgo.svg', + currency: 'West African CFA franc' + }, + { + name: 'Tokelau', + capital: 'Fakaofo', + languages: ['English'], + population: 1411, + flag: 'https://restcountries.eu/data/tkl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Tonga', + capital: "Nuku'alofa", + languages: ['English', 'Tonga (Tonga Islands)'], + population: 103252, + flag: 'https://restcountries.eu/data/ton.svg', + currency: 'Tongan paʻanga' + }, + { + name: 'Trinidad and Tobago', + capital: 'Port of Spain', + languages: ['English'], + population: 1349667, + flag: 'https://restcountries.eu/data/tto.svg', + currency: 'Trinidad and Tobago dollar' + }, + { + name: 'Tunisia', + capital: 'Tunis', + languages: ['Arabic'], + population: 11154400, + flag: 'https://restcountries.eu/data/tun.svg', + currency: 'Tunisian dinar' + }, + { + name: 'Turkey', + capital: 'Ankara', + languages: ['Turkish'], + population: 78741053, + flag: 'https://restcountries.eu/data/tur.svg', + currency: 'Turkish lira' + }, + { + name: 'Turkmenistan', + capital: 'Ashgabat', + languages: ['Turkmen', 'Russian'], + population: 4751120, + flag: 'https://restcountries.eu/data/tkm.svg', + currency: 'Turkmenistan manat' + }, + { + name: 'Turks and Caicos Islands', + capital: 'Cockburn Town', + languages: ['English'], + population: 31458, + flag: 'https://restcountries.eu/data/tca.svg', + currency: 'United States dollar' + }, + { + name: 'Tuvalu', + capital: 'Funafuti', + languages: ['English'], + population: 10640, + flag: 'https://restcountries.eu/data/tuv.svg', + currency: 'Australian dollar' + }, + { + name: 'Uganda', + capital: 'Kampala', + languages: ['English', 'Swahili'], + population: 33860700, + flag: 'https://restcountries.eu/data/uga.svg', + currency: 'Ugandan shilling' + }, + { + name: 'Ukraine', + capital: 'Kiev', + languages: ['Ukrainian'], + population: 42692393, + flag: 'https://restcountries.eu/data/ukr.svg', + currency: 'Ukrainian hryvnia' + }, + { + name: 'United Arab Emirates', + capital: 'Abu Dhabi', + languages: ['Arabic'], + population: 9856000, + flag: 'https://restcountries.eu/data/are.svg', + currency: 'United Arab Emirates dirham' + }, + { + name: 'United Kingdom of Great Britain and Northern Ireland', + capital: 'London', + languages: ['English'], + population: 65110000, + flag: 'https://restcountries.eu/data/gbr.svg', + currency: 'British pound' + }, + { + name: 'United States of America', + capital: 'Washington, D.C.', + languages: ['English'], + population: 323947000, + flag: 'https://restcountries.eu/data/usa.svg', + currency: 'United States dollar' + }, + { + name: 'Uruguay', + capital: 'Montevideo', + languages: ['Spanish'], + population: 3480222, + flag: 'https://restcountries.eu/data/ury.svg', + currency: 'Uruguayan peso' + }, + { + name: 'Uzbekistan', + capital: 'Tashkent', + languages: ['Uzbek', 'Russian'], + population: 31576400, + flag: 'https://restcountries.eu/data/uzb.svg', + currency: "Uzbekistani so'm" + }, + { + name: 'Vanuatu', + capital: 'Port Vila', + languages: ['Bislama', 'English', 'French'], + population: 277500, + flag: 'https://restcountries.eu/data/vut.svg', + currency: 'Vanuatu vatu' + }, + { + name: 'Venezuela (Bolivarian Republic of)', + capital: 'Caracas', + languages: ['Spanish'], + population: 31028700, + flag: 'https://restcountries.eu/data/ven.svg', + currency: 'Venezuelan bolívar' + }, + { + name: 'Viet Nam', + capital: 'Hanoi', + languages: ['Vietnamese'], + population: 92700000, + flag: 'https://restcountries.eu/data/vnm.svg', + currency: 'Vietnamese đồng' + }, + { + name: 'Wallis and Futuna', + capital: 'Mata-Utu', + languages: ['French'], + population: 11750, + flag: 'https://restcountries.eu/data/wlf.svg', + currency: 'CFP franc' + }, + { + name: 'Western Sahara', + capital: 'El Aaiún', + languages: ['Spanish'], + population: 510713, + flag: 'https://restcountries.eu/data/esh.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Yemen', + capital: "Sana'a", + languages: ['Arabic'], + population: 27478000, + flag: 'https://restcountries.eu/data/yem.svg', + currency: 'Yemeni rial' + }, + { + name: 'Zambia', + capital: 'Lusaka', + languages: ['English'], + population: 15933883, + flag: 'https://restcountries.eu/data/zmb.svg', + currency: 'Zambian kwacha' + }, + { + name: 'Zimbabwe', + capital: 'Harare', + languages: ['English', 'Shona', 'Northern Ndebele'], + population: 14240168, + flag: 'https://restcountries.eu/data/zwe.svg', + currency: 'Botswana pula' + } +] diff --git a/29_Day_Mini_project_animating_characters/29_day_starters/project_2/index.html b/29_Day_Mini_project_animating_characters/29_day_starters/project_2/index.html new file mode 100644 index 0000000..5c2da5e --- /dev/null +++ b/29_Day_Mini_project_animating_characters/29_day_starters/project_2/index.html @@ -0,0 +1,17 @@ + + + + + 30DaysOfJavaScript: Day 29 - Project 2 + + + + + + + + + + + + \ No newline at end of file diff --git a/29_Day_Mini_project_animating_characters/29_day_starters/project_2/scripts/main.js b/29_Day_Mini_project_animating_characters/29_day_starters/project_2/scripts/main.js new file mode 100644 index 0000000..c6045c8 --- /dev/null +++ b/29_Day_Mini_project_animating_characters/29_day_starters/project_2/scripts/main.js @@ -0,0 +1,2 @@ +console.log(countries) +alert('Open the console and check if the countries has been loaded') \ No newline at end of file diff --git a/30_Day_Mini_project_final/30_day_mini_project_final.md b/30_Day_Mini_project_final/30_day_mini_project_final.md new file mode 100644 index 0000000..1e69248 --- /dev/null +++ b/30_Day_Mini_project_final/30_day_mini_project_final.md @@ -0,0 +1,59 @@ +
    +

    30 Days Of JavaScript: Final Projects

    + + + + + Twitter Follow + + +Author: +Asabeneh Yetayeh
    + January, 2020 +
    +
    + + +
    + +Support [**Asabeneh**](https://www.patreon.com/asabeneh?fan_landing=true) to create more educational materials +[become-asabeneh-patreon](https://www.patreon.com/asabeneh?fan_landing=true) + +
    + +[<< Day 29](../29_Day_Mini_project_animating_characters/29_day_mini_project_animating_characters.md) + +![Thirty Days Of JavaScript](../images/banners/day_1_30.png) + +- [Day 30](#day-30) + - [Exercises](#exercises) + - [Exercise: Level 1](#exercise-level-1) + - [Exercise: Level 2](#exercise-level-2) + - [Exercise: Level 3](#exercise-level-3) + +# Day 30 + +## Exercises + +### Exercise: Level 1 + +1. Create the following animation using (HTML, CSS, JS) + +![Countries daata](./../images/projects/dom_mini_project_countries_object_day_10.1.gif) + +2. Validate the following form using regex. + + ![form validation](./../images/projects/dom_mini_project_form_validation_day_10.2.1.png) + + ![form validation](./../images/projects/dom_mini_project_form_validation_day_10.2.png) + + +### Exercise: Level 2 + +### Exercise: Level 3 + +🌕 Your journey to greatness completed successfully. You reached high level of greatness. Now, you are much greater than ever before. I knew what it takes to reach to this level and you made to this point. You are a real hero. Now, it is time to celebrate your success with a friend or with a family. I am looking forward to seeing you in an other challenge. + +~![Congratulations](./../images/projects/congratulations.gif) + +[<< Day 29](../29_Day_Mini_project_animating_characters/29_day_mini_project_animating_characters.md) diff --git a/30_Day_Mini_project_final/30_day_starters/project_1/data/countries_data.js b/30_Day_Mini_project_final/30_day_starters/project_1/data/countries_data.js new file mode 100644 index 0000000..92acddd --- /dev/null +++ b/30_Day_Mini_project_final/30_day_starters/project_1/data/countries_data.js @@ -0,0 +1,2013 @@ +const countries = [ + { + name: 'Afghanistan', + capital: 'Kabul', + languages: ['Pashto', 'Uzbek', 'Turkmen'], + population: 27657145, + flag: 'https://restcountries.eu/data/afg.svg', + currency: 'Afghan afghani' + }, + { + name: 'Åland Islands', + capital: 'Mariehamn', + languages: ['Swedish'], + population: 28875, + flag: 'https://restcountries.eu/data/ala.svg', + currency: 'Euro' + }, + { + name: 'Albania', + capital: 'Tirana', + languages: ['Albanian'], + population: 2886026, + flag: 'https://restcountries.eu/data/alb.svg', + currency: 'Albanian lek' + }, + { + name: 'Algeria', + capital: 'Algiers', + languages: ['Arabic'], + population: 40400000, + flag: 'https://restcountries.eu/data/dza.svg', + currency: 'Algerian dinar' + }, + { + name: 'American Samoa', + capital: 'Pago Pago', + languages: ['English', 'Samoan'], + population: 57100, + flag: 'https://restcountries.eu/data/asm.svg', + currency: 'United State Dollar' + }, + { + name: 'Andorra', + capital: 'Andorra la Vella', + languages: ['Catalan'], + population: 78014, + flag: 'https://restcountries.eu/data/and.svg', + currency: 'Euro' + }, + { + name: 'Angola', + capital: 'Luanda', + languages: ['Portuguese'], + population: 25868000, + flag: 'https://restcountries.eu/data/ago.svg', + currency: 'Angolan kwanza' + }, + { + name: 'Anguilla', + capital: 'The Valley', + languages: ['English'], + population: 13452, + flag: 'https://restcountries.eu/data/aia.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Antarctica', + capital: '', + languages: ['English', 'Russian'], + population: 1000, + flag: 'https://restcountries.eu/data/ata.svg', + currency: 'Australian dollar' + }, + { + name: 'Antigua and Barbuda', + capital: "Saint John's", + languages: ['English'], + population: 86295, + flag: 'https://restcountries.eu/data/atg.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Argentina', + capital: 'Buenos Aires', + languages: ['Spanish', 'Guaraní'], + population: 43590400, + flag: 'https://restcountries.eu/data/arg.svg', + currency: 'Argentine peso' + }, + { + name: 'Armenia', + capital: 'Yerevan', + languages: ['Armenian', 'Russian'], + population: 2994400, + flag: 'https://restcountries.eu/data/arm.svg', + currency: 'Armenian dram' + }, + { + name: 'Aruba', + capital: 'Oranjestad', + languages: ['Dutch', '(Eastern) Punjabi'], + population: 107394, + flag: 'https://restcountries.eu/data/abw.svg', + currency: 'Aruban florin' + }, + { + name: 'Australia', + capital: 'Canberra', + languages: ['English'], + population: 24117360, + flag: 'https://restcountries.eu/data/aus.svg', + currency: 'Australian dollar' + }, + { + name: 'Austria', + capital: 'Vienna', + languages: ['German'], + population: 8725931, + flag: 'https://restcountries.eu/data/aut.svg', + currency: 'Euro' + }, + { + name: 'Azerbaijan', + capital: 'Baku', + languages: ['Azerbaijani'], + population: 9730500, + flag: 'https://restcountries.eu/data/aze.svg', + currency: 'Azerbaijani manat' + }, + { + name: 'Bahamas', + capital: 'Nassau', + languages: ['English'], + population: 378040, + flag: 'https://restcountries.eu/data/bhs.svg', + currency: 'Bahamian dollar' + }, + { + name: 'Bahrain', + capital: 'Manama', + languages: ['Arabic'], + population: 1404900, + flag: 'https://restcountries.eu/data/bhr.svg', + currency: 'Bahraini dinar' + }, + { + name: 'Bangladesh', + capital: 'Dhaka', + languages: ['Bengali'], + population: 161006790, + flag: 'https://restcountries.eu/data/bgd.svg', + currency: 'Bangladeshi taka' + }, + { + name: 'Barbados', + capital: 'Bridgetown', + languages: ['English'], + population: 285000, + flag: 'https://restcountries.eu/data/brb.svg', + currency: 'Barbadian dollar' + }, + { + name: 'Belarus', + capital: 'Minsk', + languages: ['Belarusian', 'Russian'], + population: 9498700, + flag: 'https://restcountries.eu/data/blr.svg', + currency: 'New Belarusian ruble' + }, + { + name: 'Belgium', + capital: 'Brussels', + languages: ['Dutch', 'French', 'German'], + population: 11319511, + flag: 'https://restcountries.eu/data/bel.svg', + currency: 'Euro' + }, + { + name: 'Belize', + capital: 'Belmopan', + languages: ['English', 'Spanish'], + population: 370300, + flag: 'https://restcountries.eu/data/blz.svg', + currency: 'Belize dollar' + }, + { + name: 'Benin', + capital: 'Porto-Novo', + languages: ['French'], + population: 10653654, + flag: 'https://restcountries.eu/data/ben.svg', + currency: 'West African CFA franc' + }, + { + name: 'Bermuda', + capital: 'Hamilton', + languages: ['English'], + population: 61954, + flag: 'https://restcountries.eu/data/bmu.svg', + currency: 'Bermudian dollar' + }, + { + name: 'Bhutan', + capital: 'Thimphu', + languages: ['Dzongkha'], + population: 775620, + flag: 'https://restcountries.eu/data/btn.svg', + currency: 'Bhutanese ngultrum' + }, + { + name: 'Bolivia (Plurinational State of)', + capital: 'Sucre', + languages: ['Spanish', 'Aymara', 'Quechua'], + population: 10985059, + flag: 'https://restcountries.eu/data/bol.svg', + currency: 'Bolivian boliviano' + }, + { + name: 'Bonaire, Sint Eustatius and Saba', + capital: 'Kralendijk', + languages: ['Dutch'], + population: 17408, + flag: 'https://restcountries.eu/data/bes.svg', + currency: 'United States dollar' + }, + { + name: 'Bosnia and Herzegovina', + capital: 'Sarajevo', + languages: ['Bosnian', 'Croatian', 'Serbian'], + population: 3531159, + flag: 'https://restcountries.eu/data/bih.svg', + currency: 'Bosnia and Herzegovina convertible mark' + }, + { + name: 'Botswana', + capital: 'Gaborone', + languages: ['English', 'Tswana'], + population: 2141206, + flag: 'https://restcountries.eu/data/bwa.svg', + currency: 'Botswana pula' + }, + { + name: 'Bouvet Island', + capital: '', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 0, + flag: 'https://restcountries.eu/data/bvt.svg', + currency: 'Norwegian krone' + }, + { + name: 'Brazil', + capital: 'Brasília', + languages: ['Portuguese'], + population: 206135893, + flag: 'https://restcountries.eu/data/bra.svg', + currency: 'Brazilian real' + }, + { + name: 'British Indian Ocean Territory', + capital: 'Diego Garcia', + languages: ['English'], + population: 3000, + flag: 'https://restcountries.eu/data/iot.svg', + currency: 'United States dollar' + }, + { + name: 'United States Minor Outlying Islands', + capital: '', + languages: ['English'], + population: 300, + flag: 'https://restcountries.eu/data/umi.svg', + currency: 'United States Dollar' + }, + { + name: 'Virgin Islands (British)', + capital: 'Road Town', + languages: ['English'], + population: 28514, + flag: 'https://restcountries.eu/data/vgb.svg', + currency: '[D]' + }, + { + name: 'Virgin Islands (U.S.)', + capital: 'Charlotte Amalie', + languages: ['English'], + population: 114743, + flag: 'https://restcountries.eu/data/vir.svg', + currency: 'United States dollar' + }, + { + name: 'Brunei Darussalam', + capital: 'Bandar Seri Begawan', + languages: ['Malay'], + population: 411900, + flag: 'https://restcountries.eu/data/brn.svg', + currency: 'Brunei dollar' + }, + { + name: 'Bulgaria', + capital: 'Sofia', + languages: ['Bulgarian'], + population: 7153784, + flag: 'https://restcountries.eu/data/bgr.svg', + currency: 'Bulgarian lev' + }, + { + name: 'Burkina Faso', + capital: 'Ouagadougou', + languages: ['French', 'Fula'], + population: 19034397, + flag: 'https://restcountries.eu/data/bfa.svg', + currency: 'West African CFA franc' + }, + { + name: 'Burundi', + capital: 'Bujumbura', + languages: ['French', 'Kirundi'], + population: 10114505, + flag: 'https://restcountries.eu/data/bdi.svg', + currency: 'Burundian franc' + }, + { + name: 'Cambodia', + capital: 'Phnom Penh', + languages: ['Khmer'], + population: 15626444, + flag: 'https://restcountries.eu/data/khm.svg', + currency: 'Cambodian riel' + }, + { + name: 'Cameroon', + capital: 'Yaoundé', + languages: ['English', 'French'], + population: 22709892, + flag: 'https://restcountries.eu/data/cmr.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Canada', + capital: 'Ottawa', + languages: ['English', 'French'], + population: 36155487, + flag: 'https://restcountries.eu/data/can.svg', + currency: 'Canadian dollar' + }, + { + name: 'Cabo Verde', + capital: 'Praia', + languages: ['Portuguese'], + population: 531239, + flag: 'https://restcountries.eu/data/cpv.svg', + currency: 'Cape Verdean escudo' + }, + { + name: 'Cayman Islands', + capital: 'George Town', + languages: ['English'], + population: 58238, + flag: 'https://restcountries.eu/data/cym.svg', + currency: 'Cayman Islands dollar' + }, + { + name: 'Central African Republic', + capital: 'Bangui', + languages: ['French', 'Sango'], + population: 4998000, + flag: 'https://restcountries.eu/data/caf.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chad', + capital: "N'Djamena", + languages: ['French', 'Arabic'], + population: 14497000, + flag: 'https://restcountries.eu/data/tcd.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Chile', + capital: 'Santiago', + languages: ['Spanish'], + population: 18191900, + flag: 'https://restcountries.eu/data/chl.svg', + currency: 'Chilean peso' + }, + { + name: 'China', + capital: 'Beijing', + languages: ['Chinese'], + population: 1377422166, + flag: 'https://restcountries.eu/data/chn.svg', + currency: 'Chinese yuan' + }, + { + name: 'Christmas Island', + capital: 'Flying Fish Cove', + languages: ['English'], + population: 2072, + flag: 'https://restcountries.eu/data/cxr.svg', + currency: 'Australian dollar' + }, + { + name: 'Cocos (Keeling) Islands', + capital: 'West Island', + languages: ['English'], + population: 550, + flag: 'https://restcountries.eu/data/cck.svg', + currency: 'Australian dollar' + }, + { + name: 'Colombia', + capital: 'Bogotá', + languages: ['Spanish'], + population: 48759958, + flag: 'https://restcountries.eu/data/col.svg', + currency: 'Colombian peso' + }, + { + name: 'Comoros', + capital: 'Moroni', + languages: ['Arabic', 'French'], + population: 806153, + flag: 'https://restcountries.eu/data/com.svg', + currency: 'Comorian franc' + }, + { + name: 'Congo', + capital: 'Brazzaville', + languages: ['French', 'Lingala'], + population: 4741000, + flag: 'https://restcountries.eu/data/cog.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Congo (Democratic Republic of the)', + capital: 'Kinshasa', + languages: ['French', 'Lingala', 'Kongo', 'Swahili', 'Luba-Katanga'], + population: 85026000, + flag: 'https://restcountries.eu/data/cod.svg', + currency: 'Congolese franc' + }, + { + name: 'Cook Islands', + capital: 'Avarua', + languages: ['English'], + population: 18100, + flag: 'https://restcountries.eu/data/cok.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Costa Rica', + capital: 'San José', + languages: ['Spanish'], + population: 4890379, + flag: 'https://restcountries.eu/data/cri.svg', + currency: 'Costa Rican colón' + }, + { + name: 'Croatia', + capital: 'Zagreb', + languages: ['Croatian'], + population: 4190669, + flag: 'https://restcountries.eu/data/hrv.svg', + currency: 'Croatian kuna' + }, + { + name: 'Cuba', + capital: 'Havana', + languages: ['Spanish'], + population: 11239004, + flag: 'https://restcountries.eu/data/cub.svg', + currency: 'Cuban convertible peso' + }, + { + name: 'Curaçao', + capital: 'Willemstad', + languages: ['Dutch', '(Eastern) Punjabi', 'English'], + population: 154843, + flag: 'https://restcountries.eu/data/cuw.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Cyprus', + capital: 'Nicosia', + languages: ['Greek (modern)', 'Turkish', 'Armenian'], + population: 847000, + flag: 'https://restcountries.eu/data/cyp.svg', + currency: 'Euro' + }, + { + name: 'Czech Republic', + capital: 'Prague', + languages: ['Czech', 'Slovak'], + population: 10558524, + flag: 'https://restcountries.eu/data/cze.svg', + currency: 'Czech koruna' + }, + { + name: 'Denmark', + capital: 'Copenhagen', + languages: ['Danish'], + population: 5717014, + flag: 'https://restcountries.eu/data/dnk.svg', + currency: 'Danish krone' + }, + { + name: 'Djibouti', + capital: 'Djibouti', + languages: ['French', 'Arabic'], + population: 900000, + flag: 'https://restcountries.eu/data/dji.svg', + currency: 'Djiboutian franc' + }, + { + name: 'Dominica', + capital: 'Roseau', + languages: ['English'], + population: 71293, + flag: 'https://restcountries.eu/data/dma.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Dominican Republic', + capital: 'Santo Domingo', + languages: ['Spanish'], + population: 10075045, + flag: 'https://restcountries.eu/data/dom.svg', + currency: 'Dominican peso' + }, + { + name: 'Ecuador', + capital: 'Quito', + languages: ['Spanish'], + population: 16545799, + flag: 'https://restcountries.eu/data/ecu.svg', + currency: 'United States dollar' + }, + { + name: 'Egypt', + capital: 'Cairo', + languages: ['Arabic'], + population: 91290000, + flag: 'https://restcountries.eu/data/egy.svg', + currency: 'Egyptian pound' + }, + { + name: 'El Salvador', + capital: 'San Salvador', + languages: ['Spanish'], + population: 6520675, + flag: 'https://restcountries.eu/data/slv.svg', + currency: 'United States dollar' + }, + { + name: 'Equatorial Guinea', + capital: 'Malabo', + languages: ['Spanish', 'French'], + population: 1222442, + flag: 'https://restcountries.eu/data/gnq.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Eritrea', + capital: 'Asmara', + languages: ['Tigrinya', 'Arabic', 'English'], + population: 5352000, + flag: 'https://restcountries.eu/data/eri.svg', + currency: 'Eritrean nakfa' + }, + { + name: 'Estonia', + capital: 'Tallinn', + languages: ['Estonian'], + population: 1315944, + flag: 'https://restcountries.eu/data/est.svg', + currency: 'Euro' + }, + { + name: 'Ethiopia', + capital: 'Addis Ababa', + languages: ['Amharic'], + population: 92206005, + flag: 'https://restcountries.eu/data/eth.svg', + currency: 'Ethiopian birr' + }, + { + name: 'Falkland Islands (Malvinas)', + capital: 'Stanley', + languages: ['English'], + population: 2563, + flag: 'https://restcountries.eu/data/flk.svg', + currency: 'Falkland Islands pound' + }, + { + name: 'Faroe Islands', + capital: 'Tórshavn', + languages: ['Faroese'], + population: 49376, + flag: 'https://restcountries.eu/data/fro.svg', + currency: 'Danish krone' + }, + { + name: 'Fiji', + capital: 'Suva', + languages: ['English', 'Fijian', 'Hindi', 'Urdu'], + population: 867000, + flag: 'https://restcountries.eu/data/fji.svg', + currency: 'Fijian dollar' + }, + { + name: 'Finland', + capital: 'Helsinki', + languages: ['Finnish', 'Swedish'], + population: 5491817, + flag: 'https://restcountries.eu/data/fin.svg', + currency: 'Euro' + }, + { + name: 'France', + capital: 'Paris', + languages: ['French'], + population: 66710000, + flag: 'https://restcountries.eu/data/fra.svg', + currency: 'Euro' + }, + { + name: 'French Guiana', + capital: 'Cayenne', + languages: ['French'], + population: 254541, + flag: 'https://restcountries.eu/data/guf.svg', + currency: 'Euro' + }, + { + name: 'French Polynesia', + capital: 'Papeetē', + languages: ['French'], + population: 271800, + flag: 'https://restcountries.eu/data/pyf.svg', + currency: 'CFP franc' + }, + { + name: 'French Southern Territories', + capital: 'Port-aux-Français', + languages: ['French'], + population: 140, + flag: 'https://restcountries.eu/data/atf.svg', + currency: 'Euro' + }, + { + name: 'Gabon', + capital: 'Libreville', + languages: ['French'], + population: 1802278, + flag: 'https://restcountries.eu/data/gab.svg', + currency: 'Central African CFA franc' + }, + { + name: 'Gambia', + capital: 'Banjul', + languages: ['English'], + population: 1882450, + flag: 'https://restcountries.eu/data/gmb.svg', + currency: 'Gambian dalasi' + }, + { + name: 'Georgia', + capital: 'Tbilisi', + languages: ['Georgian'], + population: 3720400, + flag: 'https://restcountries.eu/data/geo.svg', + currency: 'Georgian Lari' + }, + { + name: 'Germany', + capital: 'Berlin', + languages: ['German'], + population: 81770900, + flag: 'https://restcountries.eu/data/deu.svg', + currency: 'Euro' + }, + { + name: 'Ghana', + capital: 'Accra', + languages: ['English'], + population: 27670174, + flag: 'https://restcountries.eu/data/gha.svg', + currency: 'Ghanaian cedi' + }, + { + name: 'Gibraltar', + capital: 'Gibraltar', + languages: ['English'], + population: 33140, + flag: 'https://restcountries.eu/data/gib.svg', + currency: 'Gibraltar pound' + }, + { + name: 'Greece', + capital: 'Athens', + languages: ['Greek (modern)'], + population: 10858018, + flag: 'https://restcountries.eu/data/grc.svg', + currency: 'Euro' + }, + { + name: 'Greenland', + capital: 'Nuuk', + languages: ['Kalaallisut'], + population: 55847, + flag: 'https://restcountries.eu/data/grl.svg', + currency: 'Danish krone' + }, + { + name: 'Grenada', + capital: "St. George's", + languages: ['English'], + population: 103328, + flag: 'https://restcountries.eu/data/grd.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Guadeloupe', + capital: 'Basse-Terre', + languages: ['French'], + population: 400132, + flag: 'https://restcountries.eu/data/glp.svg', + currency: 'Euro' + }, + { + name: 'Guam', + capital: 'Hagåtña', + languages: ['English', 'Chamorro', 'Spanish'], + population: 184200, + flag: 'https://restcountries.eu/data/gum.svg', + currency: 'United States dollar' + }, + { + name: 'Guatemala', + capital: 'Guatemala City', + languages: ['Spanish'], + population: 16176133, + flag: 'https://restcountries.eu/data/gtm.svg', + currency: 'Guatemalan quetzal' + }, + { + name: 'Guernsey', + capital: 'St. Peter Port', + languages: ['English', 'French'], + population: 62999, + flag: 'https://restcountries.eu/data/ggy.svg', + currency: 'British pound' + }, + { + name: 'Guinea', + capital: 'Conakry', + languages: ['French', 'Fula'], + population: 12947000, + flag: 'https://restcountries.eu/data/gin.svg', + currency: 'Guinean franc' + }, + { + name: 'Guinea-Bissau', + capital: 'Bissau', + languages: ['Portuguese'], + population: 1547777, + flag: 'https://restcountries.eu/data/gnb.svg', + currency: 'West African CFA franc' + }, + { + name: 'Guyana', + capital: 'Georgetown', + languages: ['English'], + population: 746900, + flag: 'https://restcountries.eu/data/guy.svg', + currency: 'Guyanese dollar' + }, + { + name: 'Haiti', + capital: 'Port-au-Prince', + languages: ['French', 'Haitian'], + population: 11078033, + flag: 'https://restcountries.eu/data/hti.svg', + currency: 'Haitian gourde' + }, + { + name: 'Heard Island and McDonald Islands', + capital: '', + languages: ['English'], + population: 0, + flag: 'https://restcountries.eu/data/hmd.svg', + currency: 'Australian dollar' + }, + { + name: 'Holy See', + capital: 'Rome', + languages: ['Latin', 'Italian', 'French', 'German'], + population: 451, + flag: 'https://restcountries.eu/data/vat.svg', + currency: 'Euro' + }, + { + name: 'Honduras', + capital: 'Tegucigalpa', + languages: ['Spanish'], + population: 8576532, + flag: 'https://restcountries.eu/data/hnd.svg', + currency: 'Honduran lempira' + }, + { + name: 'Hong Kong', + capital: 'City of Victoria', + languages: ['English', 'Chinese'], + population: 7324300, + flag: 'https://restcountries.eu/data/hkg.svg', + currency: 'Hong Kong dollar' + }, + { + name: 'Hungary', + capital: 'Budapest', + languages: ['Hungarian'], + population: 9823000, + flag: 'https://restcountries.eu/data/hun.svg', + currency: 'Hungarian forint' + }, + { + name: 'Iceland', + capital: 'Reykjavík', + languages: ['Icelandic'], + population: 334300, + flag: 'https://restcountries.eu/data/isl.svg', + currency: 'Icelandic króna' + }, + { + name: 'India', + capital: 'New Delhi', + languages: ['Hindi', 'English'], + population: 1295210000, + flag: 'https://restcountries.eu/data/ind.svg', + currency: 'Indian rupee' + }, + { + name: 'Indonesia', + capital: 'Jakarta', + languages: ['Indonesian'], + population: 258705000, + flag: 'https://restcountries.eu/data/idn.svg', + currency: 'Indonesian rupiah' + }, + { + name: "Côte d'Ivoire", + capital: 'Yamoussoukro', + languages: ['French'], + population: 22671331, + flag: 'https://restcountries.eu/data/civ.svg', + currency: 'West African CFA franc' + }, + { + name: 'Iran (Islamic Republic of)', + capital: 'Tehran', + languages: ['Persian (Farsi)'], + population: 79369900, + flag: 'https://restcountries.eu/data/irn.svg', + currency: 'Iranian rial' + }, + { + name: 'Iraq', + capital: 'Baghdad', + languages: ['Arabic', 'Kurdish'], + population: 37883543, + flag: 'https://restcountries.eu/data/irq.svg', + currency: 'Iraqi dinar' + }, + { + name: 'Ireland', + capital: 'Dublin', + languages: ['Irish', 'English'], + population: 6378000, + flag: 'https://restcountries.eu/data/irl.svg', + currency: 'Euro' + }, + { + name: 'Isle of Man', + capital: 'Douglas', + languages: ['English', 'Manx'], + population: 84497, + flag: 'https://restcountries.eu/data/imn.svg', + currency: 'British pound' + }, + { + name: 'Israel', + capital: 'Jerusalem', + languages: ['Hebrew (modern)', 'Arabic'], + population: 8527400, + flag: 'https://restcountries.eu/data/isr.svg', + currency: 'Israeli new shekel' + }, + { + name: 'Italy', + capital: 'Rome', + languages: ['Italian'], + population: 60665551, + flag: 'https://restcountries.eu/data/ita.svg', + currency: 'Euro' + }, + { + name: 'Jamaica', + capital: 'Kingston', + languages: ['English'], + population: 2723246, + flag: 'https://restcountries.eu/data/jam.svg', + currency: 'Jamaican dollar' + }, + { + name: 'Japan', + capital: 'Tokyo', + languages: ['Japanese'], + population: 126960000, + flag: 'https://restcountries.eu/data/jpn.svg', + currency: 'Japanese yen' + }, + { + name: 'Jersey', + capital: 'Saint Helier', + languages: ['English', 'French'], + population: 100800, + flag: 'https://restcountries.eu/data/jey.svg', + currency: 'British pound' + }, + { + name: 'Jordan', + capital: 'Amman', + languages: ['Arabic'], + population: 9531712, + flag: 'https://restcountries.eu/data/jor.svg', + currency: 'Jordanian dinar' + }, + { + name: 'Kazakhstan', + capital: 'Astana', + languages: ['Kazakh', 'Russian'], + population: 17753200, + flag: 'https://restcountries.eu/data/kaz.svg', + currency: 'Kazakhstani tenge' + }, + { + name: 'Kenya', + capital: 'Nairobi', + languages: ['English', 'Swahili'], + population: 47251000, + flag: 'https://restcountries.eu/data/ken.svg', + currency: 'Kenyan shilling' + }, + { + name: 'Kiribati', + capital: 'South Tarawa', + languages: ['English'], + population: 113400, + flag: 'https://restcountries.eu/data/kir.svg', + currency: 'Australian dollar' + }, + { + name: 'Kuwait', + capital: 'Kuwait City', + languages: ['Arabic'], + population: 4183658, + flag: 'https://restcountries.eu/data/kwt.svg', + currency: 'Kuwaiti dinar' + }, + { + name: 'Kyrgyzstan', + capital: 'Bishkek', + languages: ['Kyrgyz', 'Russian'], + population: 6047800, + flag: 'https://restcountries.eu/data/kgz.svg', + currency: 'Kyrgyzstani som' + }, + { + name: "Lao People's Democratic Republic", + capital: 'Vientiane', + languages: ['Lao'], + population: 6492400, + flag: 'https://restcountries.eu/data/lao.svg', + currency: 'Lao kip' + }, + { + name: 'Latvia', + capital: 'Riga', + languages: ['Latvian'], + population: 1961600, + flag: 'https://restcountries.eu/data/lva.svg', + currency: 'Euro' + }, + { + name: 'Lebanon', + capital: 'Beirut', + languages: ['Arabic', 'French'], + population: 5988000, + flag: 'https://restcountries.eu/data/lbn.svg', + currency: 'Lebanese pound' + }, + { + name: 'Lesotho', + capital: 'Maseru', + languages: ['English', 'Southern Sotho'], + population: 1894194, + flag: 'https://restcountries.eu/data/lso.svg', + currency: 'Lesotho loti' + }, + { + name: 'Liberia', + capital: 'Monrovia', + languages: ['English'], + population: 4615000, + flag: 'https://restcountries.eu/data/lbr.svg', + currency: 'Liberian dollar' + }, + { + name: 'Libya', + capital: 'Tripoli', + languages: ['Arabic'], + population: 6385000, + flag: 'https://restcountries.eu/data/lby.svg', + currency: 'Libyan dinar' + }, + { + name: 'Liechtenstein', + capital: 'Vaduz', + languages: ['German'], + population: 37623, + flag: 'https://restcountries.eu/data/lie.svg', + currency: 'Swiss franc' + }, + { + name: 'Lithuania', + capital: 'Vilnius', + languages: ['Lithuanian'], + population: 2872294, + flag: 'https://restcountries.eu/data/ltu.svg', + currency: 'Euro' + }, + { + name: 'Luxembourg', + capital: 'Luxembourg', + languages: ['French', 'German', 'Luxembourgish'], + population: 576200, + flag: 'https://restcountries.eu/data/lux.svg', + currency: 'Euro' + }, + { + name: 'Macao', + capital: '', + languages: ['Chinese', 'Portuguese'], + population: 649100, + flag: 'https://restcountries.eu/data/mac.svg', + currency: 'Macanese pataca' + }, + { + name: 'Macedonia (the former Yugoslav Republic of)', + capital: 'Skopje', + languages: ['Macedonian'], + population: 2058539, + flag: 'https://restcountries.eu/data/mkd.svg', + currency: 'Macedonian denar' + }, + { + name: 'Madagascar', + capital: 'Antananarivo', + languages: ['French', 'Malagasy'], + population: 22434363, + flag: 'https://restcountries.eu/data/mdg.svg', + currency: 'Malagasy ariary' + }, + { + name: 'Malawi', + capital: 'Lilongwe', + languages: ['English', 'Chichewa'], + population: 16832910, + flag: 'https://restcountries.eu/data/mwi.svg', + currency: 'Malawian kwacha' + }, + { + name: 'Malaysia', + capital: 'Kuala Lumpur', + languages: ['Malaysian'], + population: 31405416, + flag: 'https://restcountries.eu/data/mys.svg', + currency: 'Malaysian ringgit' + }, + { + name: 'Maldives', + capital: 'Malé', + languages: ['Divehi'], + population: 344023, + flag: 'https://restcountries.eu/data/mdv.svg', + currency: 'Maldivian rufiyaa' + }, + { + name: 'Mali', + capital: 'Bamako', + languages: ['French'], + population: 18135000, + flag: 'https://restcountries.eu/data/mli.svg', + currency: 'West African CFA franc' + }, + { + name: 'Malta', + capital: 'Valletta', + languages: ['Maltese', 'English'], + population: 425384, + flag: 'https://restcountries.eu/data/mlt.svg', + currency: 'Euro' + }, + { + name: 'Marshall Islands', + capital: 'Majuro', + languages: ['English', 'Marshallese'], + population: 54880, + flag: 'https://restcountries.eu/data/mhl.svg', + currency: 'United States dollar' + }, + { + name: 'Martinique', + capital: 'Fort-de-France', + languages: ['French'], + population: 378243, + flag: 'https://restcountries.eu/data/mtq.svg', + currency: 'Euro' + }, + { + name: 'Mauritania', + capital: 'Nouakchott', + languages: ['Arabic'], + population: 3718678, + flag: 'https://restcountries.eu/data/mrt.svg', + currency: 'Mauritanian ouguiya' + }, + { + name: 'Mauritius', + capital: 'Port Louis', + languages: ['English'], + population: 1262879, + flag: 'https://restcountries.eu/data/mus.svg', + currency: 'Mauritian rupee' + }, + { + name: 'Mayotte', + capital: 'Mamoudzou', + languages: ['French'], + population: 226915, + flag: 'https://restcountries.eu/data/myt.svg', + currency: 'Euro' + }, + { + name: 'Mexico', + capital: 'Mexico City', + languages: ['Spanish'], + population: 122273473, + flag: 'https://restcountries.eu/data/mex.svg', + currency: 'Mexican peso' + }, + { + name: 'Micronesia (Federated States of)', + capital: 'Palikir', + languages: ['English'], + population: 102800, + flag: 'https://restcountries.eu/data/fsm.svg', + currency: '[D]' + }, + { + name: 'Moldova (Republic of)', + capital: 'Chișinău', + languages: ['Romanian'], + population: 3553100, + flag: 'https://restcountries.eu/data/mda.svg', + currency: 'Moldovan leu' + }, + { + name: 'Monaco', + capital: 'Monaco', + languages: ['French'], + population: 38400, + flag: 'https://restcountries.eu/data/mco.svg', + currency: 'Euro' + }, + { + name: 'Mongolia', + capital: 'Ulan Bator', + languages: ['Mongolian'], + population: 3093100, + flag: 'https://restcountries.eu/data/mng.svg', + currency: 'Mongolian tögrög' + }, + { + name: 'Montenegro', + capital: 'Podgorica', + languages: ['Serbian', 'Bosnian', 'Albanian', 'Croatian'], + population: 621810, + flag: 'https://restcountries.eu/data/mne.svg', + currency: 'Euro' + }, + { + name: 'Montserrat', + capital: 'Plymouth', + languages: ['English'], + population: 4922, + flag: 'https://restcountries.eu/data/msr.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Morocco', + capital: 'Rabat', + languages: ['Arabic'], + population: 33337529, + flag: 'https://restcountries.eu/data/mar.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Mozambique', + capital: 'Maputo', + languages: ['Portuguese'], + population: 26423700, + flag: 'https://restcountries.eu/data/moz.svg', + currency: 'Mozambican metical' + }, + { + name: 'Myanmar', + capital: 'Naypyidaw', + languages: ['Burmese'], + population: 51419420, + flag: 'https://restcountries.eu/data/mmr.svg', + currency: 'Burmese kyat' + }, + { + name: 'Namibia', + capital: 'Windhoek', + languages: ['English', 'Afrikaans'], + population: 2324388, + flag: 'https://restcountries.eu/data/nam.svg', + currency: 'Namibian dollar' + }, + { + name: 'Nauru', + capital: 'Yaren', + languages: ['English', 'Nauruan'], + population: 10084, + flag: 'https://restcountries.eu/data/nru.svg', + currency: 'Australian dollar' + }, + { + name: 'Nepal', + capital: 'Kathmandu', + languages: ['Nepali'], + population: 28431500, + flag: 'https://restcountries.eu/data/npl.svg', + currency: 'Nepalese rupee' + }, + { + name: 'Netherlands', + capital: 'Amsterdam', + languages: ['Dutch'], + population: 17019800, + flag: 'https://restcountries.eu/data/nld.svg', + currency: 'Euro' + }, + { + name: 'New Caledonia', + capital: 'Nouméa', + languages: ['French'], + population: 268767, + flag: 'https://restcountries.eu/data/ncl.svg', + currency: 'CFP franc' + }, + { + name: 'New Zealand', + capital: 'Wellington', + languages: ['English', 'Māori'], + population: 4697854, + flag: 'https://restcountries.eu/data/nzl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Nicaragua', + capital: 'Managua', + languages: ['Spanish'], + population: 6262703, + flag: 'https://restcountries.eu/data/nic.svg', + currency: 'Nicaraguan córdoba' + }, + { + name: 'Niger', + capital: 'Niamey', + languages: ['French'], + population: 20715000, + flag: 'https://restcountries.eu/data/ner.svg', + currency: 'West African CFA franc' + }, + { + name: 'Nigeria', + capital: 'Abuja', + languages: ['English'], + population: 186988000, + flag: 'https://restcountries.eu/data/nga.svg', + currency: 'Nigerian naira' + }, + { + name: 'Niue', + capital: 'Alofi', + languages: ['English'], + population: 1470, + flag: 'https://restcountries.eu/data/niu.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Norfolk Island', + capital: 'Kingston', + languages: ['English'], + population: 2302, + flag: 'https://restcountries.eu/data/nfk.svg', + currency: 'Australian dollar' + }, + { + name: "Korea (Democratic People's Republic of)", + capital: 'Pyongyang', + languages: ['Korean'], + population: 25281000, + flag: 'https://restcountries.eu/data/prk.svg', + currency: 'North Korean won' + }, + { + name: 'Northern Mariana Islands', + capital: 'Saipan', + languages: ['English', 'Chamorro'], + population: 56940, + flag: 'https://restcountries.eu/data/mnp.svg', + currency: 'United States dollar' + }, + { + name: 'Norway', + capital: 'Oslo', + languages: ['Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk'], + population: 5223256, + flag: 'https://restcountries.eu/data/nor.svg', + currency: 'Norwegian krone' + }, + { + name: 'Oman', + capital: 'Muscat', + languages: ['Arabic'], + population: 4420133, + flag: 'https://restcountries.eu/data/omn.svg', + currency: 'Omani rial' + }, + { + name: 'Pakistan', + capital: 'Islamabad', + languages: ['English', 'Urdu'], + population: 194125062, + flag: 'https://restcountries.eu/data/pak.svg', + currency: 'Pakistani rupee' + }, + { + name: 'Palau', + capital: 'Ngerulmud', + languages: ['English'], + population: 17950, + flag: 'https://restcountries.eu/data/plw.svg', + currency: '[E]' + }, + { + name: 'Palestine, State of', + capital: 'Ramallah', + languages: ['Arabic'], + population: 4682467, + flag: 'https://restcountries.eu/data/pse.svg', + currency: 'Israeli new sheqel' + }, + { + name: 'Panama', + capital: 'Panama City', + languages: ['Spanish'], + population: 3814672, + flag: 'https://restcountries.eu/data/pan.svg', + currency: 'Panamanian balboa' + }, + { + name: 'Papua New Guinea', + capital: 'Port Moresby', + languages: ['English'], + population: 8083700, + flag: 'https://restcountries.eu/data/png.svg', + currency: 'Papua New Guinean kina' + }, + { + name: 'Paraguay', + capital: 'Asunción', + languages: ['Spanish', 'Guaraní'], + population: 6854536, + flag: 'https://restcountries.eu/data/pry.svg', + currency: 'Paraguayan guaraní' + }, + { + name: 'Peru', + capital: 'Lima', + languages: ['Spanish'], + population: 31488700, + flag: 'https://restcountries.eu/data/per.svg', + currency: 'Peruvian sol' + }, + { + name: 'Philippines', + capital: 'Manila', + languages: ['English'], + population: 103279800, + flag: 'https://restcountries.eu/data/phl.svg', + currency: 'Philippine peso' + }, + { + name: 'Pitcairn', + capital: 'Adamstown', + languages: ['English'], + population: 56, + flag: 'https://restcountries.eu/data/pcn.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Poland', + capital: 'Warsaw', + languages: ['Polish'], + population: 38437239, + flag: 'https://restcountries.eu/data/pol.svg', + currency: 'Polish złoty' + }, + { + name: 'Portugal', + capital: 'Lisbon', + languages: ['Portuguese'], + population: 10374822, + flag: 'https://restcountries.eu/data/prt.svg', + currency: 'Euro' + }, + { + name: 'Puerto Rico', + capital: 'San Juan', + languages: ['Spanish', 'English'], + population: 3474182, + flag: 'https://restcountries.eu/data/pri.svg', + currency: 'United States dollar' + }, + { + name: 'Qatar', + capital: 'Doha', + languages: ['Arabic'], + population: 2587564, + flag: 'https://restcountries.eu/data/qat.svg', + currency: 'Qatari riyal' + }, + { + name: 'Republic of Kosovo', + capital: 'Pristina', + languages: ['Albanian', 'Serbian'], + population: 1733842, + flag: 'https://restcountries.eu/data/kos.svg', + currency: 'Euro' + }, + { + name: 'Réunion', + capital: 'Saint-Denis', + languages: ['French'], + population: 840974, + flag: 'https://restcountries.eu/data/reu.svg', + currency: 'Euro' + }, + { + name: 'Romania', + capital: 'Bucharest', + languages: ['Romanian'], + population: 19861408, + flag: 'https://restcountries.eu/data/rou.svg', + currency: 'Romanian leu' + }, + { + name: 'Russian Federation', + capital: 'Moscow', + languages: ['Russian'], + population: 146599183, + flag: 'https://restcountries.eu/data/rus.svg', + currency: 'Russian ruble' + }, + { + name: 'Rwanda', + capital: 'Kigali', + languages: ['Kinyarwanda', 'English', 'French'], + population: 11553188, + flag: 'https://restcountries.eu/data/rwa.svg', + currency: 'Rwandan franc' + }, + { + name: 'Saint Barthélemy', + capital: 'Gustavia', + languages: ['French'], + population: 9417, + flag: 'https://restcountries.eu/data/blm.svg', + currency: 'Euro' + }, + { + name: 'Saint Helena, Ascension and Tristan da Cunha', + capital: 'Jamestown', + languages: ['English'], + population: 4255, + flag: 'https://restcountries.eu/data/shn.svg', + currency: 'Saint Helena pound' + }, + { + name: 'Saint Kitts and Nevis', + capital: 'Basseterre', + languages: ['English'], + population: 46204, + flag: 'https://restcountries.eu/data/kna.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Lucia', + capital: 'Castries', + languages: ['English'], + population: 186000, + flag: 'https://restcountries.eu/data/lca.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Saint Martin (French part)', + capital: 'Marigot', + languages: ['English', 'French', 'Dutch'], + population: 36979, + flag: 'https://restcountries.eu/data/maf.svg', + currency: 'Euro' + }, + { + name: 'Saint Pierre and Miquelon', + capital: 'Saint-Pierre', + languages: ['French'], + population: 6069, + flag: 'https://restcountries.eu/data/spm.svg', + currency: 'Euro' + }, + { + name: 'Saint Vincent and the Grenadines', + capital: 'Kingstown', + languages: ['English'], + population: 109991, + flag: 'https://restcountries.eu/data/vct.svg', + currency: 'East Caribbean dollar' + }, + { + name: 'Samoa', + capital: 'Apia', + languages: ['Samoan', 'English'], + population: 194899, + flag: 'https://restcountries.eu/data/wsm.svg', + currency: 'Samoan tālā' + }, + { + name: 'San Marino', + capital: 'City of San Marino', + languages: ['Italian'], + population: 33005, + flag: 'https://restcountries.eu/data/smr.svg', + currency: 'Euro' + }, + { + name: 'Sao Tome and Principe', + capital: 'São Tomé', + languages: ['Portuguese'], + population: 187356, + flag: 'https://restcountries.eu/data/stp.svg', + currency: 'São Tomé and Príncipe dobra' + }, + { + name: 'Saudi Arabia', + capital: 'Riyadh', + languages: ['Arabic'], + population: 32248200, + flag: 'https://restcountries.eu/data/sau.svg', + currency: 'Saudi riyal' + }, + { + name: 'Senegal', + capital: 'Dakar', + languages: ['French'], + population: 14799859, + flag: 'https://restcountries.eu/data/sen.svg', + currency: 'West African CFA franc' + }, + { + name: 'Serbia', + capital: 'Belgrade', + languages: ['Serbian'], + population: 7076372, + flag: 'https://restcountries.eu/data/srb.svg', + currency: 'Serbian dinar' + }, + { + name: 'Seychelles', + capital: 'Victoria', + languages: ['French', 'English'], + population: 91400, + flag: 'https://restcountries.eu/data/syc.svg', + currency: 'Seychellois rupee' + }, + { + name: 'Sierra Leone', + capital: 'Freetown', + languages: ['English'], + population: 7075641, + flag: 'https://restcountries.eu/data/sle.svg', + currency: 'Sierra Leonean leone' + }, + { + name: 'Singapore', + capital: 'Singapore', + languages: ['English', 'Malay', 'Tamil', 'Chinese'], + population: 5535000, + flag: 'https://restcountries.eu/data/sgp.svg', + currency: 'Brunei dollar' + }, + { + name: 'Sint Maarten (Dutch part)', + capital: 'Philipsburg', + languages: ['Dutch', 'English'], + population: 38247, + flag: 'https://restcountries.eu/data/sxm.svg', + currency: 'Netherlands Antillean guilder' + }, + { + name: 'Slovakia', + capital: 'Bratislava', + languages: ['Slovak'], + population: 5426252, + flag: 'https://restcountries.eu/data/svk.svg', + currency: 'Euro' + }, + { + name: 'Slovenia', + capital: 'Ljubljana', + languages: ['Slovene'], + population: 2064188, + flag: 'https://restcountries.eu/data/svn.svg', + currency: 'Euro' + }, + { + name: 'Solomon Islands', + capital: 'Honiara', + languages: ['English'], + population: 642000, + flag: 'https://restcountries.eu/data/slb.svg', + currency: 'Solomon Islands dollar' + }, + { + name: 'Somalia', + capital: 'Mogadishu', + languages: ['Somali', 'Arabic'], + population: 11079000, + flag: 'https://restcountries.eu/data/som.svg', + currency: 'Somali shilling' + }, + { + name: 'South Africa', + capital: 'Pretoria', + languages: [ + 'Afrikaans', + 'English', + 'Southern Ndebele', + 'Southern Sotho', + 'Swati', + 'Tswana', + 'Tsonga', + 'Venda', + 'Xhosa', + 'Zulu' + ], + population: 55653654, + flag: 'https://restcountries.eu/data/zaf.svg', + currency: 'South African rand' + }, + { + name: 'South Georgia and the South Sandwich Islands', + capital: 'King Edward Point', + languages: ['English'], + population: 30, + flag: 'https://restcountries.eu/data/sgs.svg', + currency: 'British pound' + }, + { + name: 'Korea (Republic of)', + capital: 'Seoul', + languages: ['Korean'], + population: 50801405, + flag: 'https://restcountries.eu/data/kor.svg', + currency: 'South Korean won' + }, + { + name: 'South Sudan', + capital: 'Juba', + languages: ['English'], + population: 12131000, + flag: 'https://restcountries.eu/data/ssd.svg', + currency: 'South Sudanese pound' + }, + { + name: 'Spain', + capital: 'Madrid', + languages: ['Spanish'], + population: 46438422, + flag: 'https://restcountries.eu/data/esp.svg', + currency: 'Euro' + }, + { + name: 'Sri Lanka', + capital: 'Colombo', + languages: ['Sinhalese', 'Tamil'], + population: 20966000, + flag: 'https://restcountries.eu/data/lka.svg', + currency: 'Sri Lankan rupee' + }, + { + name: 'Sudan', + capital: 'Khartoum', + languages: ['Arabic', 'English'], + population: 39598700, + flag: 'https://restcountries.eu/data/sdn.svg', + currency: 'Sudanese pound' + }, + { + name: 'Suriname', + capital: 'Paramaribo', + languages: ['Dutch'], + population: 541638, + flag: 'https://restcountries.eu/data/sur.svg', + currency: 'Surinamese dollar' + }, + { + name: 'Svalbard and Jan Mayen', + capital: 'Longyearbyen', + languages: ['Norwegian'], + population: 2562, + flag: 'https://restcountries.eu/data/sjm.svg', + currency: 'Norwegian krone' + }, + { + name: 'Swaziland', + capital: 'Lobamba', + languages: ['English', 'Swati'], + population: 1132657, + flag: 'https://restcountries.eu/data/swz.svg', + currency: 'Swazi lilangeni' + }, + { + name: 'Sweden', + capital: 'Stockholm', + languages: ['Swedish'], + population: 9894888, + flag: 'https://restcountries.eu/data/swe.svg', + currency: 'Swedish krona' + }, + { + name: 'Switzerland', + capital: 'Bern', + languages: ['German', 'French', 'Italian'], + population: 8341600, + flag: 'https://restcountries.eu/data/che.svg', + currency: 'Swiss franc' + }, + { + name: 'Syrian Arab Republic', + capital: 'Damascus', + languages: ['Arabic'], + population: 18564000, + flag: 'https://restcountries.eu/data/syr.svg', + currency: 'Syrian pound' + }, + { + name: 'Taiwan', + capital: 'Taipei', + languages: ['Chinese'], + population: 23503349, + flag: 'https://restcountries.eu/data/twn.svg', + currency: 'New Taiwan dollar' + }, + { + name: 'Tajikistan', + capital: 'Dushanbe', + languages: ['Tajik', 'Russian'], + population: 8593600, + flag: 'https://restcountries.eu/data/tjk.svg', + currency: 'Tajikistani somoni' + }, + { + name: 'Tanzania, United Republic of', + capital: 'Dodoma', + languages: ['Swahili', 'English'], + population: 55155000, + flag: 'https://restcountries.eu/data/tza.svg', + currency: 'Tanzanian shilling' + }, + { + name: 'Thailand', + capital: 'Bangkok', + languages: ['Thai'], + population: 65327652, + flag: 'https://restcountries.eu/data/tha.svg', + currency: 'Thai baht' + }, + { + name: 'Timor-Leste', + capital: 'Dili', + languages: ['Portuguese'], + population: 1167242, + flag: 'https://restcountries.eu/data/tls.svg', + currency: 'United States dollar' + }, + { + name: 'Togo', + capital: 'Lomé', + languages: ['French'], + population: 7143000, + flag: 'https://restcountries.eu/data/tgo.svg', + currency: 'West African CFA franc' + }, + { + name: 'Tokelau', + capital: 'Fakaofo', + languages: ['English'], + population: 1411, + flag: 'https://restcountries.eu/data/tkl.svg', + currency: 'New Zealand dollar' + }, + { + name: 'Tonga', + capital: "Nuku'alofa", + languages: ['English', 'Tonga (Tonga Islands)'], + population: 103252, + flag: 'https://restcountries.eu/data/ton.svg', + currency: 'Tongan paʻanga' + }, + { + name: 'Trinidad and Tobago', + capital: 'Port of Spain', + languages: ['English'], + population: 1349667, + flag: 'https://restcountries.eu/data/tto.svg', + currency: 'Trinidad and Tobago dollar' + }, + { + name: 'Tunisia', + capital: 'Tunis', + languages: ['Arabic'], + population: 11154400, + flag: 'https://restcountries.eu/data/tun.svg', + currency: 'Tunisian dinar' + }, + { + name: 'Turkey', + capital: 'Ankara', + languages: ['Turkish'], + population: 78741053, + flag: 'https://restcountries.eu/data/tur.svg', + currency: 'Turkish lira' + }, + { + name: 'Turkmenistan', + capital: 'Ashgabat', + languages: ['Turkmen', 'Russian'], + population: 4751120, + flag: 'https://restcountries.eu/data/tkm.svg', + currency: 'Turkmenistan manat' + }, + { + name: 'Turks and Caicos Islands', + capital: 'Cockburn Town', + languages: ['English'], + population: 31458, + flag: 'https://restcountries.eu/data/tca.svg', + currency: 'United States dollar' + }, + { + name: 'Tuvalu', + capital: 'Funafuti', + languages: ['English'], + population: 10640, + flag: 'https://restcountries.eu/data/tuv.svg', + currency: 'Australian dollar' + }, + { + name: 'Uganda', + capital: 'Kampala', + languages: ['English', 'Swahili'], + population: 33860700, + flag: 'https://restcountries.eu/data/uga.svg', + currency: 'Ugandan shilling' + }, + { + name: 'Ukraine', + capital: 'Kiev', + languages: ['Ukrainian'], + population: 42692393, + flag: 'https://restcountries.eu/data/ukr.svg', + currency: 'Ukrainian hryvnia' + }, + { + name: 'United Arab Emirates', + capital: 'Abu Dhabi', + languages: ['Arabic'], + population: 9856000, + flag: 'https://restcountries.eu/data/are.svg', + currency: 'United Arab Emirates dirham' + }, + { + name: 'United Kingdom of Great Britain and Northern Ireland', + capital: 'London', + languages: ['English'], + population: 65110000, + flag: 'https://restcountries.eu/data/gbr.svg', + currency: 'British pound' + }, + { + name: 'United States of America', + capital: 'Washington, D.C.', + languages: ['English'], + population: 323947000, + flag: 'https://restcountries.eu/data/usa.svg', + currency: 'United States dollar' + }, + { + name: 'Uruguay', + capital: 'Montevideo', + languages: ['Spanish'], + population: 3480222, + flag: 'https://restcountries.eu/data/ury.svg', + currency: 'Uruguayan peso' + }, + { + name: 'Uzbekistan', + capital: 'Tashkent', + languages: ['Uzbek', 'Russian'], + population: 31576400, + flag: 'https://restcountries.eu/data/uzb.svg', + currency: "Uzbekistani so'm" + }, + { + name: 'Vanuatu', + capital: 'Port Vila', + languages: ['Bislama', 'English', 'French'], + population: 277500, + flag: 'https://restcountries.eu/data/vut.svg', + currency: 'Vanuatu vatu' + }, + { + name: 'Venezuela (Bolivarian Republic of)', + capital: 'Caracas', + languages: ['Spanish'], + population: 31028700, + flag: 'https://restcountries.eu/data/ven.svg', + currency: 'Venezuelan bolívar' + }, + { + name: 'Viet Nam', + capital: 'Hanoi', + languages: ['Vietnamese'], + population: 92700000, + flag: 'https://restcountries.eu/data/vnm.svg', + currency: 'Vietnamese đồng' + }, + { + name: 'Wallis and Futuna', + capital: 'Mata-Utu', + languages: ['French'], + population: 11750, + flag: 'https://restcountries.eu/data/wlf.svg', + currency: 'CFP franc' + }, + { + name: 'Western Sahara', + capital: 'El Aaiún', + languages: ['Spanish'], + population: 510713, + flag: 'https://restcountries.eu/data/esh.svg', + currency: 'Moroccan dirham' + }, + { + name: 'Yemen', + capital: "Sana'a", + languages: ['Arabic'], + population: 27478000, + flag: 'https://restcountries.eu/data/yem.svg', + currency: 'Yemeni rial' + }, + { + name: 'Zambia', + capital: 'Lusaka', + languages: ['English'], + population: 15933883, + flag: 'https://restcountries.eu/data/zmb.svg', + currency: 'Zambian kwacha' + }, + { + name: 'Zimbabwe', + capital: 'Harare', + languages: ['English', 'Shona', 'Northern Ndebele'], + population: 14240168, + flag: 'https://restcountries.eu/data/zwe.svg', + currency: 'Botswana pula' + } +] diff --git a/30_Day_Mini_project_final/30_day_starters/project_1/index.html b/30_Day_Mini_project_final/30_day_starters/project_1/index.html new file mode 100644 index 0000000..323f758 --- /dev/null +++ b/30_Day_Mini_project_final/30_day_starters/project_1/index.html @@ -0,0 +1,16 @@ + + + + + 30DaysOfJavaScript:30 + + + + + + + + + + + \ No newline at end of file diff --git a/30_Day_Mini_project_final/30_day_starters/project_1/scripts/main.js b/30_Day_Mini_project_final/30_day_starters/project_1/scripts/main.js new file mode 100644 index 0000000..e69de29 diff --git a/RU/02_Day/02_day_data_types.md b/RU/02_Day/02_day_data_types.md new file mode 100644 index 0000000..e898f4f --- /dev/null +++ b/RU/02_Day/02_day_data_types.md @@ -0,0 +1,973 @@ +
    +

    30 Days Of JavaScript

    + + + + + Twitter Follow + + +Автор: +Asabeneh Yetayeh
    + Январь, 2020 +
    + +
    + +[<< День 1](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/RU/README.md) | [День 3 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/RU/03_Day/03_booleans_operators_date.md) + +![Thirty Days Of JavaScript](../images/banners/day_1_2.png) + +- [📔 Day 2](#%f0%9f%93%94-day-2) + - [Типы данных](#%d0%a2%d0%b8%d0%bf%d1%8b-%d0%b4%d0%b0%d0%bd%d0%bd%d1%8b%d1%85) + - [Примитивные типы данных](#%d0%9f%d1%80%d0%b8%d0%bc%d0%b8%d1%82%d0%b8%d0%b2%d0%bd%d1%8b%d0%b5-%d1%82%d0%b8%d0%bf%d1%8b-%d0%b4%d0%b0%d0%bd%d0%bd%d1%8b%d1%85) + - [Пример](#%d0%9f%d1%80%d0%b8%d0%bc%d0%b5%d1%80) + - [Непримитивные типы данных](#%d0%9d%d0%b5%d0%bf%d1%80%d0%b8%d0%bc%d0%b8%d1%82%d0%b8%d0%b2%d0%bd%d1%8b%d0%b5-%d1%82%d0%b8%d0%bf%d1%8b-%d0%b4%d0%b0%d0%bd%d0%bd%d1%8b%d1%85) + - [Числа](#%d0%a7%d0%b8%d1%81%d0%bb%d0%b0) + - [Объявление числовых типов данных](#%d0%9e%d0%b1%d1%8a%d1%8f%d0%b2%d0%bb%d0%b5%d0%bd%d0%b8%d0%b5-%d1%87%d0%b8%d1%81%d0%bb%d0%be%d0%b2%d1%8b%d1%85-%d1%82%d0%b8%d0%bf%d0%be%d0%b2-%d0%b4%d0%b0%d0%bd%d0%bd%d1%8b%d1%85) + - [Математический объект](#%d0%9c%d0%b0%d1%82%d0%b5%d0%bc%d0%b0%d1%82%d0%b8%d1%87%d0%b5%d1%81%d0%ba%d0%b8%d0%b9-%d0%be%d0%b1%d1%8a%d0%b5%d0%ba%d1%82) + - [Генератор случайных чисел](#%d0%93%d0%b5%d0%bd%d0%b5%d1%80%d0%b0%d1%82%d0%be%d1%80-%d1%81%d0%bb%d1%83%d1%87%d0%b0%d0%b9%d0%bd%d1%8b%d1%85-%d1%87%d0%b8%d1%81%d0%b5%d0%bb) + - [Строки](#%d0%a1%d1%82%d1%80%d0%be%d0%ba%d0%b8) + - [Конкатенация строк](#%d0%9a%d0%be%d0%bd%d0%ba%d0%b0%d1%82%d0%b5%d0%bd%d0%b0%d1%86%d0%b8%d1%8f-%d1%81%d1%82%d1%80%d0%be%d0%ba) + - [Конкатенация с использованием оператора сложения](#%d0%9a%d0%be%d0%bd%d0%ba%d0%b0%d1%82%d0%b5%d0%bd%d0%b0%d1%86%d0%b8%d1%8f-%d1%81-%d0%b8%d1%81%d0%bf%d0%be%d0%bb%d1%8c%d0%b7%d0%be%d0%b2%d0%b0%d0%bd%d0%b8%d0%b5%d0%bc-%d0%be%d0%bf%d0%b5%d1%80%d0%b0%d1%82%d0%be%d1%80%d0%b0-%d1%81%d0%bb%d0%be%d0%b6%d0%b5%d0%bd%d0%b8%d1%8f) + - [Длинные буквенные строки](#%d0%94%d0%bb%d0%b8%d0%bd%d0%bd%d1%8b%d0%b5-%d0%b1%d1%83%d0%ba%d0%b2%d0%b5%d0%bd%d0%bd%d1%8b%d0%b5-%d1%81%d1%82%d1%80%d0%be%d0%ba%d0%b8) + - [Перенос последовательности в строке](#%d0%9f%d0%b5%d1%80%d0%b5%d0%bd%d0%be%d1%81-%d0%bf%d0%be%d1%81%d0%bb%d0%b5%d0%b4%d0%be%d0%b2%d0%b0%d1%82%d0%b5%d0%bb%d1%8c%d0%bd%d0%be%d1%81%d1%82%d0%b8-%d0%b2-%d1%81%d1%82%d1%80%d0%be%d0%ba%d0%b5) + - [Шаблонные литералы (Шаблонные строки)](#%d0%a8%d0%b0%d0%b1%d0%bb%d0%be%d0%bd%d0%bd%d1%8b%d0%b5-%d0%bb%d0%b8%d1%82%d0%b5%d1%80%d0%b0%d0%bb%d1%8b-%d0%a8%d0%b0%d0%b1%d0%bb%d0%be%d0%bd%d0%bd%d1%8b%d0%b5-%d1%81%d1%82%d1%80%d0%be%d0%ba%d0%b8) + - [Строковые Методы](#%d0%a1%d1%82%d1%80%d0%be%d0%ba%d0%be%d0%b2%d1%8b%d0%b5-%d0%9c%d0%b5%d1%82%d0%be%d0%b4%d1%8b) + - [Проверка типов данных и приведение](#%d0%9f%d1%80%d0%be%d0%b2%d0%b5%d1%80%d0%ba%d0%b0-%d1%82%d0%b8%d0%bf%d0%be%d0%b2-%d0%b4%d0%b0%d0%bd%d0%bd%d1%8b%d1%85-%d0%b8-%d0%bf%d1%80%d0%b8%d0%b2%d0%b5%d0%b4%d0%b5%d0%bd%d0%b8%d0%b5) + - [Проверка типов данных](#%d0%9f%d1%80%d0%be%d0%b2%d0%b5%d1%80%d0%ba%d0%b0-%d1%82%d0%b8%d0%bf%d0%be%d0%b2-%d0%b4%d0%b0%d0%bd%d0%bd%d1%8b%d1%85) + - [Изменение типа данных (Casting)](#%d0%98%d0%b7%d0%bc%d0%b5%d0%bd%d0%b5%d0%bd%d0%b8%d0%b5-%d1%82%d0%b8%d0%bf%d0%b0-%d0%b4%d0%b0%d0%bd%d0%bd%d1%8b%d1%85-casting) + - [Строка в число](#%d0%a1%d1%82%d1%80%d0%be%d0%ba%d0%b0-%d0%b2-%d1%87%d0%b8%d1%81%d0%bb%d0%be) + - [Строка в число с плавающей запятой](#%d0%a1%d1%82%d1%80%d0%be%d0%ba%d0%b0-%d0%b2-%d1%87%d0%b8%d1%81%d0%bb%d0%be-%d1%81-%d0%bf%d0%bb%d0%b0%d0%b2%d0%b0%d1%8e%d1%89%d0%b5%d0%b9-%d0%b7%d0%b0%d0%bf%d1%8f%d1%82%d0%be%d0%b9) + - [Числа с плавающей точкой в целые числа.](#%d0%a7%d0%b8%d1%81%d0%bb%d0%b0-%d1%81-%d0%bf%d0%bb%d0%b0%d0%b2%d0%b0%d1%8e%d1%89%d0%b5%d0%b9-%d1%82%d0%be%d1%87%d0%ba%d0%be%d0%b9-%d0%b2-%d1%86%d0%b5%d0%bb%d1%8b%d0%b5-%d1%87%d0%b8%d1%81%d0%bb%d0%b0) + - [💻 День 2: Упражнения](#%f0%9f%92%bb-%d0%94%d0%b5%d0%bd%d1%8c-2-%d0%a3%d0%bf%d1%80%d0%b0%d0%b6%d0%bd%d0%b5%d0%bd%d0%b8%d1%8f) + - [Упражнение: Уровень 1](#%d0%a3%d0%bf%d1%80%d0%b0%d0%b6%d0%bd%d0%b5%d0%bd%d0%b8%d0%b5-%d0%a3%d1%80%d0%be%d0%b2%d0%b5%d0%bd%d1%8c-1) + - [Упражнение: уровень 2](#%d0%a3%d0%bf%d1%80%d0%b0%d0%b6%d0%bd%d0%b5%d0%bd%d0%b8%d0%b5-%d1%83%d1%80%d0%be%d0%b2%d0%b5%d0%bd%d1%8c-2) + - [Упражнения: уровень 3](#%d0%a3%d0%bf%d1%80%d0%b0%d0%b6%d0%bd%d0%b5%d0%bd%d0%b8%d1%8f-%d1%83%d1%80%d0%be%d0%b2%d0%b5%d0%bd%d1%8c-3) + +# 📔 Day 2 + +## Типы данных + +В предыдущем разделе мы немного упомянули о типах данных. Данные или значения имеют типы данных. Типы данных описывают характеристики данных. Типы данных можно разделить на два вида + +1. Примитивные типы данных +2. Непримитивные типы данных (ссылки на объекты) + +### Примитивные типы данных + +Примитивные типы данных в JavaScript включают в себя: + +1. Числа (Numbers) - Целые числа, числа с плавающей точкой +2. Строки (Strings) - Любые данные в одинарных или двойных кавычках +3. Булевые (boolean) - true или false значения +4. Null - пустое значение или нет значения +5. Undefined - объявленная переменная без значения + +Непримитивные типы данных в JavaScript включают в себя: + +1. Объекты +2. Функции +3. Массивы + +Теперь давайте посмотрим, что именно означают примитивные и не примитивные типы данных. + +_Примитивные_ типы данных являются неизменяемыми типами данных. Как только примитивный тип данных создан, мы не можем его изменить. + +#### Пример + +```js +let word = "JavaScript"; +``` + +Если мы попытаемся изменить строку, хранящуюся в переменной _word_, JavaScript вызовет ошибку. Любой тип данных с одинарными, двойными или обратными кавычками является строковым типом данных. + +```js +word[0] = "Y"; +``` + +Это выражение не изменяет строку, хранящуюся в переменной _word_. Таким образом, мы можем сказать, что строки не являются изменяемыми или неизменяемыми. +Примитивные типы данных сравниваются по их значениям. Давайте сравним различные значения данных. Смотрите пример ниже: + +```js +let numOne = 3; +let numTwo = 3; + +console.log(numOne == numTwo); // true + +let js = "JavaScript"; +let py = "Python"; + +console.log(js == py); //false + +let lightOn = true; +let lightOff = false; + +console.log(lightOn == lightOff); // false +``` + +### Непримитивные типы данных + +_Непримитивные_ типы данных являются изменяемыми. Мы можем изменить значение непримитивных типов данных после их создания. +Давайте посмотрим, создав массив. Массив - это список значений данных в квадратных скобках. Массивы могут содержать одинаковые или разные типы данных. На значения массива ссылается их индекс. В массиве JavaScript индекс начинается с нуля. Т.е. первый элемент массива находится с нулевым индексом, второй элемент с индексом один и третий элемент с индексом два и т.д. + +```js +let nums = [1, 2, 3]; +nums[0] = 10; + +console.log(nums); // [10, 2, 3] +``` + +Как вы можете видеть, массив, в котором непримитивный тип данных является изменяемым. Непримитивные типы данных нельзя сравнивать по значению. Даже если два непримитивных типа данных имеют одинаковые свойства и значения, они не являются строго равными. + +```js +let nums = [1, 2, 3]; +let numbers = [1, 2, 3]; + +console.log(nums == numbers); // false + +let userOne = { + name: "Asabeneh", + role: "teaching", + country: "Finland" +}; + +let userTwo = { + name: "Asabeneh", + role: "teaching", + country: "Finland" +}; + +console.log(userOne == userTwo); // false +``` + +Основное правило, мы не сравниваем непримитивные типы данных. Не сравнивайте массив, функцию или объект. +Непримитивные значения называются ссылочными типами, поскольку они сравниваются по значению, а не по значению. Два объекта строго равны, если они ссылаются на один и тот же базовый объект. + +```js +let nums = [1, 2, 3]; +let numbers = nums; + +console.log(nums == numbers); // true + +let userOne = { + name: "Asabeneh", + role: "teaching", + country: "Finland" +}; + +let userTwo = userOne; + +console.log(userOne == userTwo); // true +``` + +Если вам трудно понять разницу между примитивными типами данных и не примитивными типами данных, вы не единственный. +Успокойтесь и просто перейдите к следующему разделу и попробуйте вернуться через некоторое время. Теперь давайте начнем типы данных по типу номера. + +## Числа + +Числа представляют собой целые и десятичные значения, которые могут выполнять все арифметические операции. +Давайте посмотрим некоторые примеры чисел. + +### Объявление числовых типов данных + +```js +let age = 35; +const gravity = 9.81; //мы используем const для неизменных значений, гравитационная постоянная в m/s2 +let mass = 72; // масса в килограммах +const PI = 3.14; // ПИ геометрическая постоянная + +//Больше примеров +const boilingPoint = 100; // температура в oC, температура кипения воды которой постоянна +const bodyTemp = 37; // oC средняя температура тела человека, которая является постоянной + +console.log(age, gravity, mass, PI, boilingPoint, bodyTemp); +``` + +### Математический объект + +В JavaScript Math Object предоставляет множество методов для работы с числами. + +```js +const PI = Math.PI; + +console.log(PI); // 3.141592653589793 + +// Округление до ближайшего числа +// если выше .5 вверх, если меньше 0.5 вниз + +console.log(Math.round(PI)); // 3, чтобы округлить значения до ближайшего числа + +console.log(Math.round(9.81)); // 10 + +console.log(Math.floor(PI)); // 3 округление вниз + +console.log(Math.ceil(PI)); // 4 округление вверх + +console.log(Math.min(-5, 3, 20, 4, 5, 10)); // -5, возвращает минимальное значение + +console.log(Math.max(-5, 3, 20, 4, 5, 10)); // 20, возвращает максимальное значение + +const randNum = Math.random(); // создает случайное число от 0 до 0,999999 +console.log(randNum); + +// Давайте создадим случайное число от 0 до 10 + +const num = Math.floor(Math.random() * 11); // создает случайное число от 0 до 10 +console.log(num); + +// Абсолютное значение +console.log(Math.abs(-10)); //10 + +// Квадратный корень +console.log(Math.sqrt(100)); // 10 + +console.log(Math.sqrt(2)); //1.4142135623730951 + +// Мощность +console.log(Math.pow(3, 2)); // 9 + +console.log(Math.E); // 2.718 + +// Логарифм +// Возвращает натуральный логарифм основания E из x, Math.log(x) +console.log(Math.log(2)); // 0.6931471805599453 +console.log(Math.log(10)); // 2.302585092994046 + +// Тригонометрия +Math.sin(0); +Math.sin(60); + +Math.cos(0); +Math.cos(60); +``` + +#### Генератор случайных чисел + +JavaScript Math Object имеет генератор номеров метода `random()`, который генерирует числа от 0 до 0.999999999... + +```js +let randomNum = Math.random(); // генерирует от 0 до 0,999 +``` + +Теперь давайте посмотрим, как мы можем использовать метод `random()` для генерации случайного числа от 0 до 10 включительно. + +```js +let randomNum = Math.random(); // генерирует от 0 до 0,999 +let numBtnZeroAndTen = randomNum * 11; + +console.log(numBtnZeroAndTen); // это дает: мин 0 и макс 10.99 + +let randomNumRoundToFloor = Math.floor(numBtnZeroAndTen); +console.log(randomNumRoundToFloor); // это дает от 0 до 10 +``` + +## Строки + +Строки - это тексты, которые заключены в **_одинарную_** или **_двойную_** кавычку. Чтобы объявить строку, нам нужно имя переменной, оператор присваивания, значение в одинарных кавычках, двойные кавычки или обратные кавычки. + +Давайте посмотрим несколько примеров строки: + +```js +let space = " "; // Пусто - пробел +let firstName = "Asabeneh"; +let lastName = "Yetayeh"; +let country = "Finland"; +let city = "Helsinki"; +let language = "JavaScript"; +let job = "teacher"; +``` + +### Конкатенация строк + +Соединение двух или более строк вместе называется конкатенацией. + +```js +// Объявление разных переменных разных типов данных +let space = " "; +let firstName = "Asabeneh"; +let lastName = "Yetayeh"; +let country = "Finland"; +let city = "Helsinki"; +let language = "JavaScript"; +let job = "teacher"; +``` + +```js +let fullName = firstName + space + lastName; // конкатенация, объединение двух строк. +console.log(fullName); +``` + +```sh +Asabeneh Yetayeh +``` + +Мы можем объединять строки разными способами. + +#### Конкатенация с использованием оператора сложения + +Конкатенация с использованием оператора сложения - старый способ. Этот способ объединения утомителен и подвержен ошибкам. Полезно знать, как объединить таким способом, но я настоятельно рекомендую использовать второй способ. + +```js +// Объявление разных переменных разных типов данных +let space = " "; +let firstName = "Asabeneh"; +let lastName = "Yetayeh"; +let country = "Finland"; +let city = "Helsinki"; +let language = "JavaScript"; +let job = "teacher"; +let age = 250; +let fullName = firstName + space + lastName; + +let personInfoOne = fullName + ". I am " + age + ". I live in " + country; // ES5 + +console.log(personInfoOne); +``` + +```sh +Asabeneh Yetayeh. I am 250. I live in Finland +``` + +#### Длинные буквенные строки + +Строка может быть отдельным символом, абзацем или страницей. Если длина строки слишком велика, она не помещается в одну строку. Мы можем использовать символ обратной косой черты (\\) в конце каждой строки, чтобы указать, что строка будет продолжена на следующей строке. + +**Пример:** + +```js +const paragraph = + "My name is Asabeneh Yetayeh. I live in Finland, Helsinki.\ +I am a teacher and I love teaching. I teach HTML, CSS, JavaScript, React, Redux, \ +Node.js, Python, Data Analysis and D3.js for anyone who is interested to learn. \ +In the end of 2019, I was thinking to expand my teaching and to reach \ +to global audience and I started a Python challenge from November 20 - December 19.\ +It was one of the most rewarding and inspiring experience.\ +Now, we are in 2020. I am enjoying preparing the 30DaysOfJavaScript challenge and \ +I hope you are enjoying too."; +console.log(paragraph); +``` + +#### Перенос последовательности в строке + +В JavaScript и других языках программирования, после некоторых символов есть перенос - последовательности. Давайте посмотрим на наиболее распространенные escape-символы: + +- `\n` - Новая строка +- `\t` - Таб означает (8 пробелов) +- `\\` - Обратная косая черта +- `\'` - Одинарные кавычки (') +- `\"` - Двойные кавычки (") + +```js +console.log( + "I hope every one is enjoying the 30 Days Of JavaScript challenge.\nDo you ?" +); // line break +console.log("Days\tTopics\tExercises"); +console.log("Day 1\t3\t5"); +console.log("Day 2\t3\t5"); +console.log("Day 3\t3\t5"); +console.log("Day 4\t3\t5"); +console.log("This is a back slash symbol (\\)"); // To write a back slash +console.log('In every programming language it starts with "Hello, World!"'); +console.log("In every programming language it starts with 'Hello, World!'"); +console.log("The saying 'Seeing is Believing' is't correct in 2020"); +``` + +#### Шаблонные литералы (Шаблонные строки) + +Чтобы создать строку шаблона, мы используем два обратных ключа. Мы можем вставить данные как выражение внутри строки шаблона. Чтобы ввести данные, мы заключаем выражение в фигурную скобку (`{}`), за которой следует знак `$`. Смотрите синтаксис ниже. + +```js +// Синтаксис +`String literal text ${expression}`; +``` + +**Пример: 1** + +```js +console.log(`The sum of 2 and 3 is 5`); // статическая запись данных +let a = 2; +let b = 3; +console.log(`The sum of ${a} and ${b} is ${a + b}`); // ввод данных динамически +``` + +**Example:2** + +```js +let firstName = "Asabeneh"; +let lastName = "Yetayeh"; +let country = "Finland"; +let city = "Helsinki"; +let language = "JavaScript"; +let job = "teacher"; +let age = 250; +let fullName = firstName + " " + lastName; + +let personInfoTwo = `I am ${fullName}. I am ${age}. I live in ${country}.`; //ES6 - Метод строковой интерполяции +let personInfoThree = `I am ${fullName}. I live in ${city}, ${country}. I am a ${job}. I teach ${language}.`; +console.log(personInfoTwo); +console.log(personInfoThree); +``` + +```sh +I am Asabeneh Yetayeh. I am 250. I live in Finland. +I am Asabeneh Yetayeh. I live in Helsinki, Finland. I am a teacher. I teach JavaScript. +``` + +Используя шаблон строки или метод интерполяции строки, мы можем добавить выражение, которое может быть значением или некоторыми операциями (сравнение, арифметические операции, троичные операции). + +```js +let a = 2; +let b = 3; +console.log(`${a} is greater than ${b}: ${a > b}`); +``` + +```sh +2 is greater than 3: false +``` + +### Строковые Методы + +Все в JavaScript это объект. Строка - это примитивный тип данных, который означает, что мы не можем изменить его после создания. У строкового объекта есть много строковых методов. Существуют разные строковые методы, которые могут помочь нам работать со строками. + +1. _length_: Метод строки _length_ возвращает количество символов в строке, включая пустое пространство. + **Пример:** + + ```js + let js = "JavaScript"; + console.log(js.length); // 10 + let firstName = "Asabeneh"; + console.log(firstName.length); // 8 + ``` + +2. _Доступ к символам в строке_: мы можем получить доступ к каждому символу в строке, используя его индекс. В программировании отсчет начинается с 0. Первый индекс строки равен нулю, а последний индекс равен одному минус длина строки. + + ![Accessing sting by index](../images/string_indexes.png) + + Давайте получим доступ к различным символам в строке «JavaScript». + + ```js + let string = "JavaScript"; + let firstLetter = string[0]; + + console.log(firstLetter); // J + + let secondLetter = string[1]; // a + let thirdLetter = string[2]; + let lastLetter = string[9]; + + console.log(lastLetter); // t + + let lastIndex = string.length - 1; + + console.log(lastIndex); // 9 + console.log(string[lastIndex]); // t + ``` + +3. `toUpperCase()`: этот метод изменяет строку на заглавные буквы. + + ```js + let string = "JavaScript"; + + console.log(string.toUpperCase()); // JAVASCRIPT + + let firstName = "Asabeneh"; + + console.log(firstName.toUpperCase()); // ASABENEH + + let country = "Finland"; + + console.log(country.toUpperCase()); // FINLAND + ``` + +4. `toLowerCase()`: этот метод изменяет строку на заглавные буквы + + ```js + let string = "JavasCript"; + + console.log(string.toLowerCase()); // javascript + + let firstName = "Asabeneh"; + + console.log(firstName.toLowerCase()); // asabeneh + + let country = "Finland"; + + console.log(country.toLowerCase()); // finland + ``` + +5. `substr()`:Требуется два аргумента: начальный индекс и количество символов для нарезки. + + ```js + let string = "JavaScript"; + console.log(string.substr(4, 6)); // Script + + let country = "Finland"; + console.log(country.substr(3, 4)); // land + ``` + +6. `substring()`: Он принимает два аргумента: начальный индекс и индекс остановки, но он не включает индекс остановки. + + ```js + let string = "JavaScript"; + + console.log(string.substring(0, 4)); // Java + console.log(string.substring(4, 10)); // Script + console.log(string.substring(4)); // Script + + let country = "Finland"; + + console.log(country.substring(0, 3)); // Fin + console.log(country.substring(3, 7)); // land + console.log(country.substring(3)); // land + ``` + +7. `split()`: Метод `split()` разделяет строку в указанном месте. + + ```js + let string = "30 Days Of JavaScript"; + + console.log(string.split()); // ["30 Days Of JavaScript"] + console.log(string.split(" ")); // ["30", "Days", "Of", "JavaScript"] + + let firstName = "Asabeneh"; + + console.log(firstName.split()); // ["Asabeneh"] + console.log(firstName.split("")); // ["A", "s", "a", "b", "e", "n", "e", "h"] + + let countries = "Finland, Sweden, Norway, Denmark, and Iceland"; + + console.log(countries.split(",")); // ["Finland", " Sweden", " Norway", " Denmark", " and Iceland"] + console.log(countries.split(", ")); //  ["Finland", "Sweden", "Norway", "Denmark", "and Iceland"] + ``` + +8. `trim()`: Удаляет завершающий пробел в начале или конце строки. + + ```js + let string = " 30 Days Of JavaScript "; + + console.log(string); + console.log(string.trim(" ")); + + let firstName = " Asabeneh "; + + console.log(firstName); + console.log(firstName.trim()); + ``` + + ```sh + 30 Days Of JavasCript + 30 Days Of JavasCript + Asabeneh + Asabeneh + ``` + +9. `includes()`: принимает аргумент подстроки и проверяет, существует ли аргумент подстроки в строке. `includes()` возвращает логическое значение. Он проверяет, существует ли подстрока в строке, и возвращает true, если она существует, и false, если она не существует. + + ```js + let string = "30 Days Of JavaScript"; + + console.log(string.includes("Days")); // true + console.log(string.includes("days")); // false + console.log(string.includes("Script")); // true + console.log(string.includes("script")); // false + console.log(string.includes("java")); // false + console.log(string.includes("Java")); // true + + let country = "Finland"; + + console.log(country.includes("fin")); // false + console.log(country.includes("Fin")); // true + console.log(country.includes("land")); // true + console.log(country.includes("Land")); // false + ``` + +10. `replace()`: принимает к параметру старую подстроку и новую подстроку. + + ```js + string.replace(oldsubstring, newsubstring); + ``` + + ```js + let string = "30 Days Of JavaScript"; + console.log(string.replace("JavaScript", "Python")); // 30 Days Of Python + + let country = "Finland"; + console.log(country.replace("Fin", "Noman")); // Nomanland + ``` + +11. `charAt()`: принимает индекс и возвращает значение по этому индексу + + ```js + string.charAt(index); + ``` + + ```js + let string = "30 Days Of JavaScript"; + console.log(string.charAt(0)); // 3 + + let lastIndex = string.length - 1; + console.log(string.charAt(lastIndex)); // t + ``` + +12. `charCodeAt()`: Принимает индекс и возвращает код символа (номер ASCII) значения по этому индексу + + ```js + string.charCodeAt(index); + ``` + + ```js + let string = "30 Days Of JavaScript"; + console.log(string.charCodeAt(3)); // D ASCII number is 51 + + let lastIndex = string.length - 1; + console.log(string.charCodeAt(lastIndex)); // t ASCII is 116 + ``` + +13. `indexOf()`: Принимает подстроку, и если подстрока существует в строке, она возвращает первую позицию подстроки, если не существует, она возвращает -1 + + ```js + string.indexOf(substring); + ``` + + ```js + let string = "30 Days Of JavaScript"; + + console.log(string.indexOf("D")); // 3 + console.log(string.indexOf("Days")); // 3 + console.log(string.indexOf("days")); // -1 + console.log(string.indexOf("a")); // 4 + console.log(string.indexOf("JavaScript")); // 11 + console.log(string.indexOf("Script")); //15 + console.log(string.indexOf("script")); // -1 + ``` + +14. `lastIndexOf()`: Принимает подстроку, и если подстрока существует в строке, она возвращает последнюю позицию подстроки, если она не существует, она возвращает -1 + + ```js + //syntax + string.lastIndexOf(substring); + ``` + + ```js + let string = + "I love JavaScript. If you do not love JavaScript what else can you love."; + + console.log(string.lastIndexOf("love")); // 67 + console.log(string.lastIndexOf("you")); // 63 + console.log(string.lastIndexOf("JavaScript")); // 38 + ``` + +15. `concat()`: он принимает много подстрок и создает конкатенацию. + + ```js + string.concat(substring, substring, substring); + ``` + + ```js + let string = "30"; + console.log(string.concat("Days", "Of", "JavaScript")); // 30DaysOfJavaScript + + let country = "Fin"; + console.log(country.concat("land")); // Finland + ``` + +16. `startsWith`: он принимает подстроку в качестве аргумента и проверяет, начинается ли строка с указанной подстроки. Возвращает логическое значение (true или false). + + ```js + //syntax + string.startsWith(substring); + ``` + + ```js + let string = "Love is the best to in this world"; + + console.log(string.startsWith("Love")); // true + console.log(string.startsWith("love")); // false + console.log(string.startsWith("world")); // false + + let country = "Finland"; + + console.log(country.startsWith("Fin")); // true + console.log(country.startsWith("fin")); // false + console.log(country.startsWith("land")); // false + ``` + +17. `endsWith`: он принимает подстроку в качестве аргумента и проверяет, начинается ли строка с указанной подстроки. Возвращает логическое значение (true или false). + + ```js + string.endsWith(substring); + ``` + + ```js + let string = "Love is the best to in this world"; + + console.log(string.endsWith("world")); // true + console.log(string.endsWith("love")); // false + console.log(string.endsWith("in this world")); // true + + let country = "Finland"; + + console.log(country.endsWith("land")); // true + console.log(country.endsWith("fin")); // false + console.log(country.endsWith("Fin")); // false + ``` + +18. `search`: он принимает подстроку в качестве аргумента и возвращает индекс первого совпадения. + + ```js + string.search(substring); + ``` + + ```js + let string = + "I love JavaScript. If you do not love JavaScript what else can you love."; + console.log(string.search("love")); // 2 + ``` + +19. `match`: он принимает подстроку или шаблон регулярного выражения в качестве аргумента и возвращает массив, если есть совпадение, если нет, то возвращает ноль. Давайте посмотрим, как выглядит шаблон регулярного выражения. Он начинается с / знака и заканчивается / знаком. + + ```js + let string = "love"; + let patternOne = /love/; //без какого-либо флага + let patternTwo = /love/gi; // g-означает поиск по всему тексту, i - без учета регистра + ``` + + Match syntax + + ```js + // syntax + string.match(substring); + ``` + + ```js + let string = + "I love JavaScript. If you do not love JavaScript what else can you love."; + console.log(string.match("love")); + ``` + + ```sh + ["love", index: 2, input: "I love JavaScript. If you do not love JavaScript what else can you love.", groups: undefined] + ``` + + ```js + let pattern = /love/gi; + console.log(string.match(pattern)); // ["love", "love", "love"] + ``` + + Давайте извлечем числа из текста, используя регулярное выражение. Это не раздел регулярных выражений, не паникуйте, мы рассмотрим регулярные выражения в другом разделе. + + ```js + let txt = + "In 2019, I run 30 Days of Python. Now, in 2020 I super exited to start this challenge"; + let regEx = /\d+/; + + // d с перенос-символом означает, что d не является нормальным d, вместо этого действует цифра + // + означает одно или несколько цифр, + // если после этого есть g, значит глобальный, ищите везде. + + console.log(txt.match(regEx)); // ["2", "0", "1", "9", "3", "0", "2", "0", "2", "0"] + console.log(txt.match(/\d+/g)); // ["2019", "30", "2020"] + ``` + +20. `repeat()`: он принимает числовой аргумент и возвращает повторную версию строки. + + ```js + string.repeat(n); + ``` + + ```js + let string = "love"; + console.log(string.repeat(10)); // lovelovelovelovelovelovelovelovelovelove + ``` + +## Проверка типов данных и приведение + +### Проверка типов данных + +- Проверка типов данных: чтобы проверить тип данных определенного типа данных, мы используем `typeof` и также меняем один тип данных на другой. + +**Пример:** + +```js +// Различные типы данных JavaScript +// Давайте объявим разные типы данных + +let firstName = "Asabeneh"; // string +let lastName = "Yetayeh"; // string +let country = "Finland"; // string +let city = "Helsinki"; // string +let age = 250; // number, это не мой настоящий возраст, не переживай +let job; // undefined, потому что значение не было присвоено + +console.log(typeof "Asabeneh"); // string +console.log(typeof firstName); // string +console.log(typeof 10); // number +console.log(typeof 3.14); // number +console.log(typeof true); // boolean +console.log(typeof false); // boolean +console.log(typeof NaN); // number +console.log(typeof job); // undefined +console.log(typeof undefined); // undefined +console.log(typeof null); // object +``` + +### Изменение типа данных (Casting) + +- Приведение: преобразование одного типа данных в другой тип данных. Мы используем _parseInt()_, _parseFloat()_, _Number()_, _+sign_, _str()_. Когда мы выполняем арифметические операции, строковые числа должны быть сначала преобразованы в целое число или число с плавающей запятой, если нет, это возвращает ошибку. + +#### Строка в число + +Мы можем преобразовать номер строки в число. Любое число внутри кавычки является строковым числом. Пример номера строки: «10», «5» и т. Д. +Мы можем преобразовать строку в число, используя следующие методы: + +- parseInt() +- Number() +- Plus sign(+) + +```js +let num = "10"; +let numInt = parseInt(num); +console.log(numInt); // 10 +``` + +```js +let num = "10"; +let numInt = Number(num); + +console.log(numInt); // 10 +``` + +```js +let num = "10"; +let numInt = +num; + +console.log(numInt); // 10 +``` + +#### Строка в число с плавающей запятой + +Мы можем преобразовать число с плавающей запятой в число с плавающей запятой. Любое число с плавающей запятой внутри кавычки является строковым числом с плавающей запятой. Пример числа с плавающей запятой: «9,81», «3,14», «1,44» и т. Д. +Мы можем преобразовать строку с плавающей точкой в число, используя следующие методы: + +- parseFloat() +- Number() +- Plus sign(+) + +```js +let num = "9.81"; +let numFloat = parseFloat(num); + +console.log(numFloat); // 9.81 +``` + +```js +let num = "9.81"; +let numFloat = Number(num); + +console.log(numFloat); // 9.81 +``` + +```js +let num = "9.81"; +let numFloat = +num; + +console.log(numInt); // 9.81 +``` + +#### Числа с плавающей точкой в целые числа. + +Мы можем преобразовать числа с плавающей точкой в целые числа. +Мы используем следующий метод для преобразования float в int: + +- parseInt() + +```js +let num = 9.81; +let numInt = parseInt(num); + +console.log(numInt); // 9 +``` + +🌕 Ты обалденный. Вы только что завершили 2-й день испытаний, и вы в двух шагах от своего пути к успеху. Теперь сделайте несколько упражнений для вашего мозга и ваших мышц. + +## 💻 День 2: Упражнения + +### Упражнение: Уровень 1 + +1. Объявите вызов имени переменной и присвойте ему начальное значение **«30 дней JavaScript»**. +2. Напечатайте строку в консоли браузера, используя `console.log()` +3. Напечатайте **length** строки в консоли браузера, используя `console.log()` +4. Измените всю строку на заглавные буквы, используя метод `toUpperCase()` +5. Измените всю строку на строчные буквы, используя метод `toLowerCase()` +6. Вырежьте (нарежьте) первое слово строки, используя метод `substr()` или `substring()` +7. Вырежьте фразу _Days Of JavaScript_ из _30 Days Of JavaScript_. +8. Проверьте, содержит ли строка слово **Script**, используя метод `includes()` +9. Разбейте **строку** на **массив**, используя метод `split()` +10. Разбить строку 30 Days Of JavaScript в пространстве с помощью метода `split()` +11. «Facebook, Google, Microsoft, Apple, IBM, Oracle, Amazon» **разбивают** строку на запятую и заменяют ее на массив. +12. Измените 30 Days Of JavaScript на 30 Days Of Python, используя метод `replace()`. +13. Что такое символ в индексе 15 в строке «30 Days Of JavaScript», используйте метод `charAt()`. +14. Что такое код символа J в строке «30 Days Of JavaScript» с использованием `charCodeAt()` +15. Используйте `indexOf`, чтобы определить позицию первого вхождения за 30 Days Of JavaScript +16. Используйте `lastIndexOf`, чтобы определить позицию последнего вхождения в 30 Days Of JavaScript. +17. Используйте `indexOf`, чтобы найти позицию первого вхождения слова **потому что** в следующем предложении: **«Вы не можете закончить предложение, потому что, потому что, потому что это соединение»** +18. Используйте `lastIndexOf`, чтобы найти позицию последнего вхождения слова **потому что** в следующем предложении: **«Вы не можете закончить предложение, потому что, потому что потому что это соединение»** +19. Используйте `search`, чтобы найти позицию первого вхождения слова **потому что** в следующем предложении: **«Вы не можете закончить предложение, потому что, потому что потому что это соединение»** +20. Используйте `trim()`, чтобы удалить, если в начале и конце строки есть конечные пробелы. Например, «30 Days Of JavaScript». +21. Используйте метод `launchWith()` со строкой _30 Days Of JavaScript_, чтобы сделать результат верным +22. Используйте метод `setsWith()` со строкой _30 Days Of JavaScript_, чтобы сделать результат верным +23. Используйте метод `match()`, чтобы найти все за 30 Days Of JavaScript +24. Используйте `concat()` и объедините «30 Days» и «JavaScript» в одну строку «30 Days Of JavaScript» +25. Используйте метод `repeat()`, чтобы напечатать 30 Days Of JavaScript 2 раза + +### Упражнение: уровень 2 + +1. Используя `console.log()`, выведите следующее утверждение. + + ```sh + The quote 'There is no exercise better for the heart than reaching down and lifting people up.' by John Holmes teaches us to help one another. + ``` + +2. Используя `console.log()` распечатайте следующую цитату Матери Терезы. + + ```sh + "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 your hand instead." + ``` + +3. Проверьте, точно ли `typeof` '10' равен 10. Если нет, сделайте его точно равным. +4. Убедитесь, что `parseFloat('9.8')` равен 10, если не равен точно 10. +5. Проверьте, найдено ли 'on' как в Python, так и в жаргоне +6. Я надеюсь, что этот курс не полон жаргона. Проверьте, находится ли _jargon_ в предложении. +7. Сгенерируйте случайное число от 0 до 100 включительно. +8. Генерация случайного числа от 50 до 100 включительно. +9. Сгенерируйте случайное число от 0 до 255 включительно. +10. Получите доступ к символам строки «JavaScript», используя случайное число. +11. Используйте `console.log()` и управляющие символы для печати следующего шаблона. + + ```js + 1 1 1 1 1 + 2 1 2 4 8 + 3 1 3 9 27 + 4 1 4 16 64 + 5 1 5 25 125 + ``` + +12. Используйте `substr`, чтобы вырезать фразу **потому что потому что** в следующем предложении: **'Вы не можете закончить предложение, потому что потому что потому что это соединение'** + +### Упражнения: уровень 3 + +1. «Любовь - лучшая вещь в этом мире. Некоторые нашли свою любовь, а некоторые все еще ищут свою любовь. Подсчитайте количество слов любви в этом предложении. +2. Используйте `match()`, чтобы сосчитать число все потому, что в следующем предложении: **«Вы не можете закончить предложение, потому что, потому что, потому что это соединение»** +3. Очистите следующий текст и найдите наиболее часто встречающееся слова (подсказка, используйте замену и регулярный экспресс). + + ```js + const sentence = + "%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"; + ``` + +4. Рассчитайте общий годовой доход человека, извлекая цифры из следующего текста. «Он зарабатывает 5000 евро с зарплаты в месяц, годовой бонус в 10000 евро, онлайн-курсы в 15000 евро в месяц». + +🎉 ПОЗДРАВЛЯЕМ! 🎉 + +[<< День 1](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/RU/readMe.md) | [День 3 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/RU/03_Day/03_booleans_operators_date.md) diff --git a/RU/02_Day/day_1_2.png b/RU/02_Day/day_1_2.png new file mode 100644 index 0000000..0f6eefb Binary files /dev/null and b/RU/02_Day/day_1_2.png differ diff --git a/RU/03_Day/03_booleans_operators_date.md b/RU/03_Day/03_booleans_operators_date.md new file mode 100644 index 0000000..06b649c --- /dev/null +++ b/RU/03_Day/03_booleans_operators_date.md @@ -0,0 +1,649 @@ +
    +

    30 Days Of JavaScript

    + + + + + Twitter Follow + + +Автор: +Asabeneh Yetayeh
    + Январь, 2020 +
    + +
    + +[<< День 2](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/02_Day/02_day_data_types.md) | [Day 4 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/04_Day/04_day_conditionals.md) + +![Thirty Days Of JavaScript](../images/banners/day_1_3.png) + +- [📔 День 3](#%f0%9f%93%94-%d0%94%d0%b5%d0%bd%d1%8c-3) + - [Булевый тип (boolean)](#%d0%91%d1%83%d0%bb%d0%b5%d0%b2%d1%8b%d0%b9-%d1%82%d0%b8%d0%bf-boolean) + - [Пример: логические значения](#%d0%9f%d1%80%d0%b8%d0%bc%d0%b5%d1%80-%d0%bb%d0%be%d0%b3%d0%b8%d1%87%d0%b5%d1%81%d0%ba%d0%b8%d0%b5-%d0%b7%d0%bd%d0%b0%d1%87%d0%b5%d0%bd%d0%b8%d1%8f) + - [Истинные значения](#%d0%98%d1%81%d1%82%d0%b8%d0%bd%d0%bd%d1%8b%d0%b5-%d0%b7%d0%bd%d0%b0%d1%87%d0%b5%d0%bd%d0%b8%d1%8f) + - [Ложные значения](#%d0%9b%d0%be%d0%b6%d0%bd%d1%8b%d0%b5-%d0%b7%d0%bd%d0%b0%d1%87%d0%b5%d0%bd%d0%b8%d1%8f) + - [Undefined](#undefined) + - [Null](#null) + - [Операторы](#%d0%9e%d0%bf%d0%b5%d1%80%d0%b0%d1%82%d0%be%d1%80%d1%8b) + - [Операторы присваивания](#%d0%9e%d0%bf%d0%b5%d1%80%d0%b0%d1%82%d0%be%d1%80%d1%8b-%d0%bf%d1%80%d0%b8%d1%81%d0%b2%d0%b0%d0%b8%d0%b2%d0%b0%d0%bd%d0%b8%d1%8f) + - [Арифметические Операторы](#%d0%90%d1%80%d0%b8%d1%84%d0%bc%d0%b5%d1%82%d0%b8%d1%87%d0%b5%d1%81%d0%ba%d0%b8%d0%b5-%d0%9e%d0%bf%d0%b5%d1%80%d0%b0%d1%82%d0%be%d1%80%d1%8b) + - [Операторы сравнения](#%d0%9e%d0%bf%d0%b5%d1%80%d0%b0%d1%82%d0%be%d1%80%d1%8b-%d1%81%d1%80%d0%b0%d0%b2%d0%bd%d0%b5%d0%bd%d0%b8%d1%8f) + - [Пример: операторы сравнения](#%d0%9f%d1%80%d0%b8%d0%bc%d0%b5%d1%80-%d0%be%d0%bf%d0%b5%d1%80%d0%b0%d1%82%d0%be%d1%80%d1%8b-%d1%81%d1%80%d0%b0%d0%b2%d0%bd%d0%b5%d0%bd%d0%b8%d1%8f) + - [Логические Операторы](#%d0%9b%d0%be%d0%b3%d0%b8%d1%87%d0%b5%d1%81%d0%ba%d0%b8%d0%b5-%d0%9e%d0%bf%d0%b5%d1%80%d0%b0%d1%82%d0%be%d1%80%d1%8b) + - [Оператор инкремента](#%d0%9e%d0%bf%d0%b5%d1%80%d0%b0%d1%82%d0%be%d1%80-%d0%b8%d0%bd%d0%ba%d1%80%d0%b5%d0%bc%d0%b5%d0%bd%d1%82%d0%b0) + - [Оператор декремента](#%d0%9e%d0%bf%d0%b5%d1%80%d0%b0%d1%82%d0%be%d1%80-%d0%b4%d0%b5%d0%ba%d1%80%d0%b5%d0%bc%d0%b5%d0%bd%d1%82%d0%b0) + - [Тернарный операторы](#%d0%a2%d0%b5%d1%80%d0%bd%d0%b0%d1%80%d0%bd%d1%8b%d0%b9-%d0%be%d0%bf%d0%b5%d1%80%d0%b0%d1%82%d0%be%d1%80%d1%8b) + - [Приоритет оператора](#%d0%9f%d1%80%d0%b8%d0%be%d1%80%d0%b8%d1%82%d0%b5%d1%82-%d0%be%d0%bf%d0%b5%d1%80%d0%b0%d1%82%d0%be%d1%80%d0%b0) + - [Методы окна](#%d0%9c%d0%b5%d1%82%d0%be%d0%b4%d1%8b-%d0%be%d0%ba%d0%bd%d0%b0) + - [Метод alert()](#%d0%9c%d0%b5%d1%82%d0%be%d0%b4-alert) + - [Метод prompt()](#%d0%9c%d0%b5%d1%82%d0%be%d0%b4-prompt) + - [Метод confirm()](#%d0%9c%d0%b5%d1%82%d0%be%d0%b4-confirm) + - [Объект Date](#%d0%9e%d0%b1%d1%8a%d0%b5%d0%ba%d1%82-date) + - [Создание объекта времени](#%d0%a1%d0%be%d0%b7%d0%b4%d0%b0%d0%bd%d0%b8%d0%b5-%d0%be%d0%b1%d1%8a%d0%b5%d0%ba%d1%82%d0%b0-%d0%b2%d1%80%d0%b5%d0%bc%d0%b5%d0%bd%d0%b8) + - [Получение года](#%d0%9f%d0%be%d0%bb%d1%83%d1%87%d0%b5%d0%bd%d0%b8%d0%b5-%d0%b3%d0%be%d0%b4%d0%b0) + - [Получение месяца](#%d0%9f%d0%be%d0%bb%d1%83%d1%87%d0%b5%d0%bd%d0%b8%d0%b5-%d0%bc%d0%b5%d1%81%d1%8f%d1%86%d0%b0) + - [Получение даты](#%d0%9f%d0%be%d0%bb%d1%83%d1%87%d0%b5%d0%bd%d0%b8%d0%b5-%d0%b4%d0%b0%d1%82%d1%8b) + - [Получение дня](#%d0%9f%d0%be%d0%bb%d1%83%d1%87%d0%b5%d0%bd%d0%b8%d0%b5-%d0%b4%d0%bd%d1%8f) + - [Получение часов](#%d0%9f%d0%be%d0%bb%d1%83%d1%87%d0%b5%d0%bd%d0%b8%d0%b5-%d1%87%d0%b0%d1%81%d0%be%d0%b2) + - [Получение минут](#%d0%9f%d0%be%d0%bb%d1%83%d1%87%d0%b5%d0%bd%d0%b8%d0%b5-%d0%bc%d0%b8%d0%bd%d1%83%d1%82) + - [Получение секунд](#%d0%9f%d0%be%d0%bb%d1%83%d1%87%d0%b5%d0%bd%d0%b8%d0%b5-%d1%81%d0%b5%d0%ba%d1%83%d0%bd%d0%b4) + - [Получение времени](#%d0%9f%d0%be%d0%bb%d1%83%d1%87%d0%b5%d0%bd%d0%b8%d0%b5-%d0%b2%d1%80%d0%b5%d0%bc%d0%b5%d0%bd%d0%b8) + - [💻 День 3: Упражнения](#%f0%9f%92%bb-%d0%94%d0%b5%d0%bd%d1%8c-3-%d0%a3%d0%bf%d1%80%d0%b0%d0%b6%d0%bd%d0%b5%d0%bd%d0%b8%d1%8f) + - [Упражнения: Уровень 1](#%d0%a3%d0%bf%d1%80%d0%b0%d0%b6%d0%bd%d0%b5%d0%bd%d0%b8%d1%8f-%d0%a3%d1%80%d0%be%d0%b2%d0%b5%d0%bd%d1%8c-1) + - [Упражнения: уровень 2](#%d0%a3%d0%bf%d1%80%d0%b0%d0%b6%d0%bd%d0%b5%d0%bd%d0%b8%d1%8f-%d1%83%d1%80%d0%be%d0%b2%d0%b5%d0%bd%d1%8c-2) + - [Упражнения: уровень 3](#%d0%a3%d0%bf%d1%80%d0%b0%d0%b6%d0%bd%d0%b5%d0%bd%d0%b8%d1%8f-%d1%83%d1%80%d0%be%d0%b2%d0%b5%d0%bd%d1%8c-3) + +# 📔 День 3 + +## Булевый тип (boolean) + +Логический тип данных представляет одно из двух значений: _true_ или _false_. Логическое значение может быть истинным или ложным. Использование этих типов данных будет понятно при запуске оператора сравнения. Любые сравнения возвращают логическое значение, которое является истинным или ложным. + +### Пример: логические значения + +```js +let isLightOn = true; +let isRaining = false; +let isHungry = false; +let isMarried = true; +let truValue = 4 > 3; // true +let falseValue = 4 < 3; // false +``` + +Мы согласились с тем, что логические значения являются истинными или ложными. + +### Истинные значения + +- Все числа (положительные и отрицательные) являются правдивыми, кроме нуля +- Все строки правдивы +- boolean истинное + +### Ложные значения + +- 0 +- 0n +- null +- undefined +- NaN +- the boolean false +- '', "", ``, пустая строка + +Нужно хорощо помнить эти истинные и ложные значения. В следующем разделе мы будем использовать их с условиями для принятия решения. + +## Undefined + +Если мы объявим переменную и не назначим значение, оно будет неопределенным. В дополнение к этому, если функция не возвращает значение, оно будет неопределенным. + +```js +let firstName; +console.log(firstName); //не определено, потому что оно еще не присвоено значению +``` + +## Null + +```js +let empty = null; +console.log(empty); // -> null , не имеет значения +``` + +## Операторы + +### Операторы присваивания + +Знак равенства в JavaScript - это оператор присваивания. Используется для присвоения переменной. + +```js +let firstName = "Asabeneh"; +let country = "Finland"; +``` + +Операторы присваивания + +![Assignment operators](../images/assignment_operators.png) + +### Арифметические Операторы + +Арифметические операторы являются математическими операторами. + +- Сложение (+): `a + b` +- Вычитание (-): `a - b` +- Умножение (_): `a _ b` +- Деление (/): `a / b` +- Остаток от деления % (%): `a % b` +- Возведение в степень (**): `a ** b` + +```js +let numOne = 4; +let numTwo = 3; +let sum = numOne + numTwo; +let diff = numOne - numTwo; +let mult = numOne * numTwo; +let div = numOne / numTwo; +let remainder = numOne % numTwo; +let powerOf = numOne ** numTwo; + +console.log(sum, diff, mult, div, remainder, powerOf); // 7,1,12,1.33,1, 64 +``` + +```js +let PI = 3.14; +let radius = 100; // длина в метрах + +const gravity = 9.81; // в m/s2 +let mass = 72; // в килограммах +const boilingPoint = 100; // температура в °С, температура кипения воды +const bodyTemp = 37; // температура тела в °С + +//Рассчитаем площадь круга +const areaOfCircle = PI * radius * radius; +console.log(areaOfCircle); // 314 m + +// Давайте посчитаем вес объекта +const weight = mass * gravity; +console.log(weight); // 706.32 N (Newton) + +//Конкатенация строк с числами с использованием строковой интерполяции +/* +Температура кипения воды составляет 100 °С. +Температура тела человека составляет 37 °С. +Гравитация земли составляет 9,81 м/с2. + */ +console.log( + `The boiling point of water is ${boilingPoint} oC.\nHuman body temperature is ${bodyTemp} oC.\nThe gravity of earth is ${gravity} m / s2.` +); +``` + +### Операторы сравнения + +В программировании мы сравниваем значения, мы используем операторы сравнения для сравнения двух значений. Мы проверяем, является ли значение больше или меньше или равно другому значению. + +![Comparison Operators](../images/comparison_operators.png) + +#### Пример: операторы сравнения + +```js +console.log(3 > 2); // true, потому что 3 больше 2 +console.log(3 >= 2); // true, потому что 3 больше 2 +console.log(3 < 2); // false, потому что 3 больше 2 +console.log(2 < 3); // true, потому что 2 меньше 3 +console.log(2 <= 3); // true, потому что 2 меньше 3 +console.log(3 == 2); // false, потому что 3 не равно 2 +console.log(3 != 2); // true, потому что 3 не равно 2 +console.log(3 == "3"); // true, сравнить только значение +console.log(3 === "3"); // false, сравнить значение и тип данных +console.log(3 !== "3"); // true, сравнить значение и тип данных +console.log(3 !== "3"); // true, сравнить значение и тип данных +console.log(3 != 3); // false, сравнить только значение +console.log(3 !== 3); // false, сравнить значение и тип данных +console.log(0 == false); // true, эквивалент +console.log(0 == ""); // true, эквивалент +console.log(0 == " "); // true, эквивалент +console.log(0 === ""); // false, не совсем то же самое +console.log(0 === false); // false, не совсем то же самое +console.log(1 == true); // true, эквивалент +console.log(1 === true); // false, не совсем то же самое +console.log(undefined == null); // true +console.log(undefined === null); // false +console.log(NaN == NaN); // false, не равный +console.log(NaN === NaN); // false +console.log(typeof NaN); // число + +console.log("mango".length == "avocado".length); // false +console.log("mango".length != "avocado".length); // true +console.log("mango".length < "avocado".length); // true +console.log("milk".length != "meat".length); // false +console.log("milk".length == "meat".length); // true +console.log("tomato".length == "potato".length); // true +console.log("python".length > "dragon".length); // false +``` + +Попытайтесь понять приведенные выше сравнения с некоторой логикой. Запоминать без какой-либо логики может быть сложно. +JavaScript - это своего рода проводной язык программирования. Код JavaScript запускается и дает вам результат, но если вы не разбираетесь в нем, это может быть нежелательным результатом. + +По практическому правилу, если значение не верно с `==`, оно не будет равно `===`. Использование `===` более безопасно, чем использование `==`. Следующая [ссылка](https://dorey.github.io/JavaScript-Equality-Table/) имеет исчерпывающий список сравнения типов данных. + +### Логические Операторы + +Следующие символы являются общими логическими операторами: `&&` (амперсанд), `||` (труба) и `!` (отрицание). + +- `&&` получает значение `true`, только если два операнда имеют значение `true`. +- `||` становится истинным, любой из операндов верен. +- `!` отрицает истину на ложь, ложь на истину. + +```js +//&& Пример оператора амперсанда + +const check = 4 > 3 && 10 > 5; // true && true -> true +const check = 4 > 3 && 10 < 5; // true && false -> false +const check = 4 < 3 && 10 < 5; // false && false -> false + +//|| pipe or operator, example + +const check = 4 > 3 || 10 > 5; // true || true -> true +const check = 4 > 3 || 10 < 5; // true || false -> true +const check = 4 < 3 || 10 < 5; // false || false -> false + +//! Примеры отрицания + +let check = 4 > 3; // true +let check = !(4 > 3); // false +let isLightOn = true; +let isLightOff = !isLightOn; // false +let isMarried = !false; // true +``` + +### Оператор инкремента + +В JavaScript мы используем оператор приращения для увеличения значения, хранящегося в переменной. Приращение может быть до или после приращения. Давайте посмотрим на каждого из них: + +1. Преинкремент + + ```js + let count = 0; + console.log(++count); // 1 + console.log(count); // 1 + ``` + +2. Пост-инкремент + + ```js + let count = 0; + console.log(count++); // 0 + console.log(count); // 1 + ``` + +Мы используем большую часть времени после приращения. По крайней мере, вы должны помнить, как использовать постинкрементный оператор. + +### Оператор декремента + +В JavaScript мы используем оператор декремента для уменьшения значения, хранящегося в переменной. Декремент может быть до или после декремента. Давайте посмотрим на каждого из них: + +1. Предекремент + + ```js + let count = 0; + console.log(--count); // -1 + console.log(count); // -1 + ``` + +2. Постдекремента + + ```js + let count = 0; + console.log(count--); // 0 + console.log(count); // -1 + ``` + +### Тернарный операторы + +Тернарный оператор позволяет записать условие. +Другой способ написания условных выражений - использование Тернарных операторов. Посмотрите на следующие примеры: + +```js +let isRaining = true; +isRaining + ? console.log("You need a rain coat.") + : console.log("No need for a rain coat."); +isRaining = false; + +isRaining + ? console.log("You need a rain coat.") + : console.log("No need for a rain coat."); +``` + +```sh +You need a rain coat. +No need for a rain coat. +``` + +```js +let number = 5; +number > 0 + ? console.log(`${number} is a positive number`) + : console.log(`${number} is a negative number`); +number = -5; + +number > 0 + ? console.log(`${number} is a positive number`) + : console.log(`${number} is a negative number`); +``` + +```sh +5 is a positive number +-5 is a negative number +``` + +### Приоритет оператора + +Я хотел бы рекомендовать вам прочитать о приоритете оператора из этой [ссылки](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence) + +## Методы окна + +### Метод alert() + +Как вы видели в самом начале, метод `alert()` отображает окно предупреждения с указанным сообщением и кнопкой OK. Это встроенный метод, и он принимает аргумент. + +```js +alert(message); +``` + +```js +alert("Welcome to 30DaysOfJavaScript"); +``` + +Не используйте слишком много предупреждений, потому что это раздражает, используйте его только для тестирования. + +### Метод prompt() + +Методы подсказки окна отображают окно подсказки с вводом в вашем браузере, чтобы принять входные значения, и входные данные могут быть сохранены в переменной. Метод `prompt()` принимает два аргумента. Второй аргумент является необязательным. + +```js +prompt("required text", "optional text"); +``` + +```js +let number = prompt("Enter number", "number goes here"); +console.log(number); +``` + +### Метод confirm() + +Метод `confirm()` отображает диалоговое окно с указанным сообщением, а также кнопки "ОК" и "Отмена". +Окно подтверждения часто используется, чтобы запросить у пользователя разрешение на что-либо. Окно `confirm()` принимает строку в качестве аргумента. +Нажатие "ОК" дает значение `true`, нажатие кнопки "Отмена" дает значение `false`. + +```js +const agree = confirm("Are you sure you like to delete? "); +console.log(agree); // результат будет true или false в зависимости от того, что вы нажимаете в диалоговом окне +``` + +These are not all the window methods we will have a separate section to go deep into window methods. + +## Объект Date + +Время это важная вещь. Нам нравится знать время определенного действия или события. В JavaScript текущее время и дата создаются с использованием JavaScript Date Object. Объект, который мы создаем с использованием объекта Date, предоставляет множество методов для работы с датой и временем. Методы, которые мы используем для получения информации о дате и времени из значений объекта даты, начинаются со слова _get_, поскольку они предоставляют информацию. + +- `getFullYear()`, +- `getMonths()`, +- `getDate()`, +- `getDay()`, +- `getHours()`, +- `getMinutes`, +- `getSeconds()`, +- `getMilliseconds()`, +- `getTime()`, +- `getDay()` + +![Date time Object](../images/date_time_object.png) + +### Создание объекта времени + +Однажды мы создаем объект времени. Объект времени предоставит информацию о времени. Давайте создадим объект времени + +```js +const now = new Date(); +console.log(now); // Sat Jan 04 2020 00:56:41 GMT+0200 (Eastern European Standard Time) +``` + +Мы создали объект времени, и мы можем получить доступ к любой информации о дате и времени из объекта, используя методы get, которые мы упомянули в таблице. + +### Получение года + +Давайте извлечем или получим полный объект времени. + +```js +const now = new Date(); +console.log(now.getFullYear()); // 2020 +``` + +### Получение месяца + +Давайте извлечем или получим месяц из объекта времени. + +```js +const now = new Date(); +console.log(now.getMonth()); // 0, потому, что месяц январь, month(0-11) +``` + +### Получение даты + +Давайте извлечем или получим дату месяца из объекта времени. + +```js +const now = new Date(); +console.log(now.getDate()); // 4, потому что день месяца 4th, day(0-31) +``` + +### Получение дня + +Давайте извлечем или получим день недели из объекта времени. + +```js +const now = new Date(); +console.log(now.getDay()); // 6, потому, что день Суббота, который является 5-м днем, +// Получение дня недели в виде числа (0-6) +``` + +### Получение часов + +Давайте извлекать или получать часы из объекта времени. + +```js +const now = new Date(); +console.log(now.getHours()); // 0, потому, что время 00:56:41 +``` + +### Получение минут + +Давайте извлекать или получать минуты из объекта времени. + +```js +const now = new Date(); +console.log(now.getMinutes()); // 56, потому, что время 00:56:41 +``` + +### Получение секунд + +Давайте извлекать или получать секунды из объекта времени. + +```js +const now = new Date(); +console.log(now.getSeconds()); // 41, потому, что время 00:56:41 +``` + +### Получение времени + +Этот метод дает время в миллисекундах, начиная с 1 января 1970 года. Он также известен как время Unix. Мы можем получить время Unix двумя способами: + +1. Используя `getTime()` + + ```js + const now = new Date(); // + console.log(now.getTime()); // 1578092201341, это количество секунд, прошедших с January 1, 1970 to January 4, 2020 00:56:41 + ``` + +2. Используя _Date.now()_ + +```js +const allSeconds = Date.now(); // +console.log(allSeconds); // 1578092201341, это количество секунд, прошедших с January 1, 1970 to January 4, 2020 00:56:41 + +const timeInSeconds = new Date().getTime(); +console.log(allSeconds == timeInSeconds); // true +``` + +Давайте отформатируем эти значения в удобочитаемом формате времени. + +**Пример:** + +```js +const now = new Date(); +const year = now.getFullYear(); // вернет year +const month = now.getMonth() + 1; // вернет month(0 - 11) +const date = now.getDate(); // вернет date (1 - 31) +const hours = now.getHours(); // вернет number (0 - 23) +const minutes = now.getMinutes(); // вернет number (0 -59) + +console.log(`${date}/${month}/${year} ${hours}:${minutes}`); // 4/1/2020 0:56 +``` + +🌕 У вас есть безграничная энергия! Вы только что выполнили 3-й день испытаний, и вы на три шага на пути к успеху. Теперь сделайте несколько упражнений для вашего мозга и ваших мышц. + +## 💻 День 3: Упражнения + +### Упражнения: Уровень 1 + +1. Объявите переменные firstName, lastName, страну, город, возраст, isMarried, year, присвойте ей значение и используйте оператор `typeof` для проверки разных типов данных. +2. Проверьте, равен ли тип «10» 10 +3. Проверьте, равен ли `parseInt ('9.8')` 10 +4. Булево значение равно либо true, либо false. + + 1. Напишите три утверждения JavaScript, которые обеспечивают значение `true`. + 2. Напишите три оператора JavaScript, которые предоставляют значения `false`. + +5. Сначала выясните результат следующего выражения сравнения без использования `console.log()`. После того, как вы определите результат, подтвердите его, используя `console.log()`. + + 1. 4 > 3 + 2. 4 >= 3 + 3. 4 < 3 + 4. 4 <= 3 + 5. 4 == 4 + 6. 4 === 4 + 7. 4 != 4 + 8. 4 !== 4 + 9. 4 != '4' + 10. 4 == '4' + 11. 4 === '4' + 12. Найдите длину python и jargon и сделайте ложное сравнение. + +6. Сначала выясните результат следующих выражений без использования `console.log()`. После того, как вы определите результат, подтвердите его с помощью `console.log()`. + + 1. 4 > 3 && 10 < 12 + 2. 4 > 3 && 10 > 12 + 3. 4 > 3 || 10 < 12 + 4. 4 > 3 || 10 > 12 + 5. !(4 > 3) + 6. !(4 < 3) + 7. !(false) + 8. !(4 > 3 && 10 < 12) + 9. !(4 > 3 && 10 > 12) + 10. !(4 === '4') + 11. В обоих случаях нет 'on' + +7. Используйте объект Date для выполнения следующих действий +     1. Какой сегодня год? +     2. Какой сегодня месяц, как число? +     3. Какая сегодня дата? +     4. Какой сегодня день, как число? +     5. Сколько сейчас часов? +     6. Какие минуты сейчас? +     7. Узнайте количество секунд, прошедших с 1 января 1970 года по настоящее время. + +### Упражнения: уровень 2 + +1. Напишите скрипт, который предложит пользователю ввести основание и высоту треугольника и рассчитать площадь треугольника. (прлощадь = 0.5 x b x h). + + ```sh + Введите основанеи: 20 + Введите высоту: 10 + Площадь треугольника 50 + ``` + +2. Напишите скрипт, который предложит пользователю ввести сторону a, сторону b и сторону c треугольника и вычислить периметр треугольника. (периметр = a + b + c) + + ```sh + Введите сторону a: 5 + Введите сторону b: 4 + Введите сторону c: 3 + Периметр треугольника 12 + ``` + +3. Получите длину и ширину, используя подсказку, и вычислите площадь прямоугольника (площадь = длина х ширина и периметр прямоугольника (периметр = 2 х (длина + ширина)) +4. Получите радиус, используя подсказку, и вычислите площадь круга (площадь = pi x r x r) и окружность круга (c = 2 x pi x r), где pi = 3.14. +5. Рассчитайте наклон, x-пересечение и y-пересечение y = 2x -2 +6. Наклон (m = y2-y1 / x2-x1). Найти наклон между точкой (2, 2) и точкой (6,10) +7. Сравните наклон двух приведенных выше вопросов. +8. Рассчитайте значение y (y = x ^ 2 + 6x + 9). Попробуйте использовать разные значения х и выяснить, при каком значении х у 0. +9. Напишите скрипт, который побудит пользователя вводить часы и ставку за час. Рассчитать зарплату человека? + + ```sh + Введите часы: 40 + Введите ставку в час: 28 + Ваш еженедельный заработок 1120 + ``` + +10. Если длина вашего имени больше 7, скажем, ваше имя длинное, иначе скажем, ваше имя короткое. +11. Сравните длину вашего имени и длину вашей фамилии, и вы должны получить этот вывод. + + ```js + let firstName = "Asabeneh"; + let lastName = "Yetayeh"; + ``` + + ```sh + Твое имя, Asabeneh длиннее вашей фамилии, Yetayeh + ``` + +12. Объявите две переменные _myAge_ и _yourAge_ и присвойте им начальные значения, myAge и yourAge. + + ```js + let myAge = 250; + let yourAge = 25; + ``` + + ```sh + Я на 225 лет старше тебя. + ``` + +13. Используя подсказку, укажите год рождения пользователя и, если ему исполнилось 18 лет, разрешите ему ехать, если он не скажет пользователю подождать определенное количество лет. + + ```sh + Введите год рождения: 1995 + Вам 25. Вы достаточно взрослый, чтобы водить + + Введите год рождения: 2005 + Вам 15. Вам будет разрешено водить после 3 лет. + ``` + +14. Напишите скрипт, который предложит пользователю ввести количество лет. Подсчитайте, сколько секунд человек может прожить. Предположим, кто-то живет всего сто лет + + ```sh + Введите число, в котором вы живете: 100 + + Вы жили 3153600000 секунд. + ``` + +15. Создайте удобочитаемый формат времени, используя объект Date time + 1. YYY-MM-DD HH:mm + 2. DD-MM-YYYY HH:mm + 3. DD/MM/YYY HH:mm + +### Упражнения: уровень 3 + +1. Создайте удобочитаемый формат времени, используя объект Date time. Час и минута должны быть все время двузначными (7 часов должны быть 07, а 5 минут должны быть 05) + 1. YYY-MM-DD HH:mm eg. 20120-01-02 07:05 + +🎉 ПОЗДРАВЛЯЕМ! 🎉 + +[<< День 2](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/RU/02_Day/02_day_data_types.md) | [День 4 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/RU/04_Day/04_day_conditionals.md) diff --git a/RU/04_Day/04_day_conditionals.md b/RU/04_Day/04_day_conditionals.md new file mode 100644 index 0000000..e306cdf --- /dev/null +++ b/RU/04_Day/04_day_conditionals.md @@ -0,0 +1,351 @@ +
    +

    30 Days Of JavaScript

    + + + + + Twitter Follow + + +Автор: +Asabeneh Yetayeh
    + Январь, 2020 +
    + +
    + +[<< День 3](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/RU/03_Day/03_booleans_operators_date.md) | [День 5 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/RU/05_Day/05_day_arrays.md) + +![Thirty Days Of JavaScript](../images/banners/day_1_4.png) + +- [📔 День 4](#%f0%9f%93%94-%d0%94%d0%b5%d0%bd%d1%8c-4) + - [Условные операторы](#%d0%a3%d1%81%d0%bb%d0%be%d0%b2%d0%bd%d1%8b%d0%b5-%d0%be%d0%bf%d0%b5%d1%80%d0%b0%d1%82%d0%be%d1%80%d1%8b) + - [if](#if) + - [if else](#if-else) + - [if else if else](#if-else-if-else) + - [Switch](#switch) + - [Тернарный оператор](#%d0%a2%d0%b5%d1%80%d0%bd%d0%b0%d1%80%d0%bd%d1%8b%d0%b9-%d0%be%d0%bf%d0%b5%d1%80%d0%b0%d1%82%d0%be%d1%80) + - [💻 Упражнения](#%f0%9f%92%bb-%d0%a3%d0%bf%d1%80%d0%b0%d0%b6%d0%bd%d0%b5%d0%bd%d0%b8%d1%8f) + - [Упражнения: уровень 1](#%d0%a3%d0%bf%d1%80%d0%b0%d0%b6%d0%bd%d0%b5%d0%bd%d0%b8%d1%8f-%d1%83%d1%80%d0%be%d0%b2%d0%b5%d0%bd%d1%8c-1) + - [Упражнения: уровень 2](#%d0%a3%d0%bf%d1%80%d0%b0%d0%b6%d0%bd%d0%b5%d0%bd%d0%b8%d1%8f-%d1%83%d1%80%d0%be%d0%b2%d0%b5%d0%bd%d1%8c-2) + - [Упражнения: уровень 3](#%d0%a3%d0%bf%d1%80%d0%b0%d0%b6%d0%bd%d0%b5%d0%bd%d0%b8%d1%8f-%d1%83%d1%80%d0%be%d0%b2%d0%b5%d0%bd%d1%8c-3) + +# 📔 День 4 + +## Условные операторы + +Условные операторы используются для принятия решения на основе различных условий. +По умолчанию операторы в скрипте JavaScript выполняются последовательно сверху вниз. Если логика обработки требует этого, последовательный поток выполнения может быть изменен двумя способами: + +- Условное выполнение: блок из одного или нескольких операторов будет выполнен, если определенное выражение истинно +- Повторное выполнение: блок из одного или нескольких операторов будет выполняться повторно, если определенное выражение истинно. В этом разделе мы рассмотрим операторы `if`, `else`, `else if`. Здесь будут полезны сравнение и логический оператор, который мы изучили в предыдущих разделах. + +Условия могут быть реализованы следующими способами: + +- if +- if else +- if else if else +- switch +- ternary operator + +### if + +В JavaScript и других языках программирования ключевое слово `if` используется, чтобы проверить, выполняется ли условие и выполнить код блока. Чтобы создать условие `if`, нам нужно ключевое слово `if`, условие внутри скобки и блок кода внутри фигурной скобки ({}). + +```js +// синтаксис +if (condition) { + //эта часть кода работает для true состояния +} +``` + +**Пример:** + +```js +let num = 3; +if (num > 0) { + console.log(`${num} это положительное число`); +} +// 3 это положительное число +``` + +```js +let isRaining = true; +if (isRaining) { + console.log("Remember to take your rain coat."); +} +``` + +Как видно из вышеприведенного условия, 3 больше 0 и является положительным числом. Условие было выполнено, и код блока был выполнен. Однако, если условие ложно, мы не видим результат. То же самое касается второго условия, если isRaining равен `false`, блок `if` не будет выполнен, и мы не увидим вывод. Чтобы увидеть результат ложного условия, у нас должен быть еще один блок, который будет `else`. + +### if else + +Если условие истинно, первый блок будет выполнен, если нет, будет выполнено условие else. + +```js +// синтаксис +if (condition) { + // эта часть кода работает для истинного состояния +} else { + // эта часть кода выполняется для ложного условия +} +``` + +```js +let num = 3; +if (num > 0) { + console.log(`${num} это положительное число`); +} else { + console.log(`${num} отрицательное число`); +} +// 3 это положительное число + +num = -3; +if (num > 0) { + console.log(`${num} это положительное число`); +} else { + console.log(`${num} это отрицательное число`); +} +// -3 это отрицательное число +``` + +```js +let isRaining = true; +if (isRaining) { + console.log("Тебе нужен плащ от дождя.."); +} else { + console.log("Не нужно пальто от дождя."); +} +// Тебе нужен плащ от дождя. + +isRaining = false; +if (isRaining) { + console.log("Тебе нужен плащ от дождя.."); +} else { + console.log("Не нужно пальто от дождя."); +} +// Не нужно пальто от дождя. +``` + +Вышеуказанное условие ложно, поэтому был выполнен блок `else`. Как насчет, если наше условие больше двух, мы будем использовать `else if` условия. + +### if else if else + +В нашей повседневной жизни мы принимаем решения ежедневно. Мы принимаем решение не проверяя одно или два условия, а принимаем решения на основе нескольких условий. Как и в нашей повседневной жизни, программирование также полно условий. Мы используем `else if`, когда у нас есть несколько условий. + +```js +// синтаксис +if (condition) { + // код +} else if (condition) { + // код +} else { + // код +} +``` + +**Пример:** + +```js +let a = 0; +if (a > 0) { + console.log(`${a} это положительное число`); +} else if (a < 0) { + console.log(`${a} это отрицательное число`); +} else if (a == 0) { + console.log(`${a} это 0`); +} else { + console.log(`${a} это не число`); +} +``` + +```js +// if else if else +let weather = "солнечно"; +if (weather === "дождливо") { + console.log("Вам нужен плащ от дождя."); +} else if (weather === "облачно") { + console.log("Может быть холодно, тебе нужен пиджак."); +} else if (weather === "солнечно") { + console.log("Выйди свободным."); +} else { + console.log("Не нужно пальто от дождя."); +} +``` + +### Switch + +Переключатель является альтернативой для `if else if else else`. +Оператор `switch` начинается с ключевого слова `switch`, за которым следуют скобки и блок кода. Внутри блока кода у нас будут разные случаи. Case case запускается, если значение в скобках оператора `switch` совпадает с case vale. Перерыв должен закончиться, и он не снижается после того, как условие выполнено. Блок по умолчанию выполняется, если все случаи не удовлетворяют условию. + +```js +switch (caseValue) { + case 1: + // код + break; + case 2: + // код + break; + case 3: + // код + default: + // код +} +``` + +```js +let weather = "облачно"; +switch (weather) { + case "дождливо": + console.log("Вам нужен плащ от дождя."); + break; + case "облачно": + console.log("Может быть холодно, тебе нужен пиджак."); + break; + case "солнечно": + console.log("Выйди свободно."); + break; + default: + console.log("Не нужно пальто от дождя."); +} + +// Switch больше примеров +let dayUserInput = prompt("Какой сегодня день ?"); +let day = dayUserInput.toLowerCase(); + +switch (day) { + case "понедельник": + console.log("Сегодня понедельник"); + break; + case "вторник": + console.log("Сегодня вторник"); + break; + case "среда": + console.log("Сегодня среда"); + break; + case "четверг": + console.log("Сегодня четверг"); + break; + case "пятница": + console.log("Сегодня пятница"); + break; + case "суббота": + console.log("Сегодня суббота"); + break; + case "воскресенье": + console.log("Сегодня воскресенье"); + break; + default: + console.log("Это не день недели."); +} +``` + +### Тернарный оператор + +Другой способ написания условных выражений - использование тернарных операторов. Мы рассмотрели это в других разделах, но мы также должны упомянуть об этом здесь. + +```js +let isRaining = true; +isRaining + ? console.log("You need a rain coat.") + : console.log("No need for a rain coat."); +``` + +🌕 Вы необыкновенный и у вас есть замечательный потенциал. Вы только что выполнили четвертый день испытаний и прошли четыре шага на пути к успеху. Теперь сделайте несколько упражнений для вашего мозга и ваших мышц. + +## 💻 Упражнения + +### Упражнения: уровень 1 + +1. Получить пользовательский ввод с помощью `prompt("Введите свой возраст:")`. Если пользователю 18 лет или больше, оставьте отзыв: вы достаточно взрослый, чтобы ездить, но если нет, то 18 - отзывайте, чтобы ждать те годы, которые он должен был ждать. + + ```sh + Введите свой возраст: 30 + Вы достаточно взрослый, чтобы водить. + + Введите свой возраст: 15 + Вам осталось 3 года до вождения. + ``` + +2. Сравните значения myAge и yourAge, используя _if… else_. На основе сравнения журнала для консоли, кто старше (я или вы). Используйте `prompt("Введите свой возраст:")`, чтобы получить возраст в качестве входных данных. + + ```sh + Введите свой возраст: 30 + Ты на 5 лет старше меня. + ``` + +3. Если a больше, чем b, вернуть «a больше, чем b», иначе «a меньше, чем b». Попробуй реализовать в пути + + - используя if else + - тернарный оператор. + + ```js + let a = 4; + let b = 3; + ``` + + ```sh + 4 больше 3 + ``` + +4. Четные числа делятся на 2, а остаток равен нулю. Как проверить, является ли число четным или нет с помощью JavaScript? + + ```sh + Введите число: 2 + 2 - четное число + + Введите число: 9 + 9 является нечетным числом. + ``` + +### Упражнения: уровень 2 + +1. Напишите код, который может дать оценку студентам в соответствии с их оценками: + - 80-100, A + - 70-89, B + - 60-69, C + - 50-59, D + - 0-49, F +2. Проверьте, является ли сезон осенью, зимой, весной или летом. + Если пользовательский ввод: + - сентябрь, октябрь или ноябрь, сезон осень. + - декабрь, январь или февраль, сезон зима. + - март, апрель или май, сезон весна + - июнь, июль или август, сезон лето +3. Проверьте, является ли день выходным или рабочим днем. Ваш сценарий примет день как вход. + + ```sh + Какой сегодня день? Суббота + Суббота - выходной день. + + Какой сегодня день? СубБоТта + Суббота - выходной день. + + Какой сегодня день? Пятница + Пятница рабочий день. + + Какой сегодня день? ПяТНИца + Пятница рабочий день. + ``` + +### Упражнения: уровень 3 + +1. Напишите программу, которая сообщает количество дней в месяце. + + ```sh + Введите месяц: январь + В январе 31 день. + + Введите месяц: ЯНВАРЬ + В январе 31 день + + Введите месяц: февраль + Февраль имеет 28 дней. + + Введите месяц: феВРаль + Февраль имеет 28 дней. + ``` + +🎉 ПОЗДРАВЛЯЕМ ! 🎉 + +[<< День 3](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/RU/03_Day/03_booleans_operators_date.md) | [День 5 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/RU/05_Day/05_day_arrays.md) diff --git a/RU/05_Day/05_day_arrays.md b/RU/05_Day/05_day_arrays.md new file mode 100644 index 0000000..24ccc68 --- /dev/null +++ b/RU/05_Day/05_day_arrays.md @@ -0,0 +1,788 @@ +
    +

    30 Days Of JavaScript

    + + + + + Twitter Follow + + +Автор: +Asabeneh Yetayeh
    + Январь, 2020 +
    + +
    + +[<< День 4](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/RU/04_Day/04_day_conditionals.md) | [День 6 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/RU/06_Day/06_day_loops.md) + +![День 5](../images/banners/day_1_5.png) + +- [📔 День 5](#%f0%9f%93%94-%d0%94%d0%b5%d0%bd%d1%8c-5) + - [Массивы](#%d0%9c%d0%b0%d1%81%d1%81%d0%b8%d0%b2%d1%8b) + - [Как создать пустой массив](#%d0%9a%d0%b0%d0%ba-%d1%81%d0%be%d0%b7%d0%b4%d0%b0%d1%82%d1%8c-%d0%bf%d1%83%d1%81%d1%82%d0%be%d0%b9-%d0%bc%d0%b0%d1%81%d1%81%d0%b8%d0%b2) + - [Как создать массив со значениями](#%d0%9a%d0%b0%d0%ba-%d1%81%d0%be%d0%b7%d0%b4%d0%b0%d1%82%d1%8c-%d0%bc%d0%b0%d1%81%d1%81%d0%b8%d0%b2-%d1%81%d0%be-%d0%b7%d0%bd%d0%b0%d1%87%d0%b5%d0%bd%d0%b8%d1%8f%d0%bc%d0%b8) + - [Создание массива с использованием split](#%d0%a1%d0%be%d0%b7%d0%b4%d0%b0%d0%bd%d0%b8%d0%b5-%d0%bc%d0%b0%d1%81%d1%81%d0%b8%d0%b2%d0%b0-%d1%81-%d0%b8%d1%81%d0%bf%d0%be%d0%bb%d1%8c%d0%b7%d0%be%d0%b2%d0%b0%d0%bd%d0%b8%d0%b5%d0%bc-split) + - [Доступ к элементам массива по индексу](#%d0%94%d0%be%d1%81%d1%82%d1%83%d0%bf-%d0%ba-%d1%8d%d0%bb%d0%b5%d0%bc%d0%b5%d0%bd%d1%82%d0%b0%d0%bc-%d0%bc%d0%b0%d1%81%d1%81%d0%b8%d0%b2%d0%b0-%d0%bf%d0%be-%d0%b8%d0%bd%d0%b4%d0%b5%d0%ba%d1%81%d1%83) + - [Изменение элемента массива](#%d0%98%d0%b7%d0%bc%d0%b5%d0%bd%d0%b5%d0%bd%d0%b8%d0%b5-%d1%8d%d0%bb%d0%b5%d0%bc%d0%b5%d0%bd%d1%82%d0%b0-%d0%bc%d0%b0%d1%81%d1%81%d0%b8%d0%b2%d0%b0) + - [Методы манипулирования массивом](#%d0%9c%d0%b5%d1%82%d0%be%d0%b4%d1%8b-%d0%bc%d0%b0%d0%bd%d0%b8%d0%bf%d1%83%d0%bb%d0%b8%d1%80%d0%be%d0%b2%d0%b0%d0%bd%d0%b8%d1%8f-%d0%bc%d0%b0%d1%81%d1%81%d0%b8%d0%b2%d0%be%d0%bc) + - [Конструктор массива](#%d0%9a%d0%be%d0%bd%d1%81%d1%82%d1%80%d1%83%d0%ba%d1%82%d0%be%d1%80-%d0%bc%d0%b0%d1%81%d1%81%d0%b8%d0%b2%d0%b0) + - [Creating static values with fill](#creating-static-values-with-fill) + - [Конкатенация массива с использованием concat](#%d0%9a%d0%be%d0%bd%d0%ba%d0%b0%d1%82%d0%b5%d0%bd%d0%b0%d1%86%d0%b8%d1%8f-%d0%bc%d0%b0%d1%81%d1%81%d0%b8%d0%b2%d0%b0-%d1%81-%d0%b8%d1%81%d0%bf%d0%be%d0%bb%d1%8c%d0%b7%d0%be%d0%b2%d0%b0%d0%bd%d0%b8%d0%b5%d0%bc-concat) + - [Получение длины массива](#%d0%9f%d0%be%d0%bb%d1%83%d1%87%d0%b5%d0%bd%d0%b8%d0%b5-%d0%b4%d0%bb%d0%b8%d0%bd%d1%8b-%d0%bc%d0%b0%d1%81%d1%81%d0%b8%d0%b2%d0%b0) + - [Получение индекса элемента в массиве arr](#%d0%9f%d0%be%d0%bb%d1%83%d1%87%d0%b5%d0%bd%d0%b8%d0%b5-%d0%b8%d0%bd%d0%b4%d0%b5%d0%ba%d1%81%d0%b0-%d1%8d%d0%bb%d0%b5%d0%bc%d0%b5%d0%bd%d1%82%d0%b0-%d0%b2-%d0%bc%d0%b0%d1%81%d1%81%d0%b8%d0%b2%d0%b5-arr) + - [Получение последнего индекса элемента в массиве](#%d0%9f%d0%be%d0%bb%d1%83%d1%87%d0%b5%d0%bd%d0%b8%d0%b5-%d0%bf%d0%be%d1%81%d0%bb%d0%b5%d0%b4%d0%bd%d0%b5%d0%b3%d0%be-%d0%b8%d0%bd%d0%b4%d0%b5%d0%ba%d1%81%d0%b0-%d1%8d%d0%bb%d0%b5%d0%bc%d0%b5%d0%bd%d1%82%d0%b0-%d0%b2-%d0%bc%d0%b0%d1%81%d1%81%d0%b8%d0%b2%d0%b5) + - [Проверка массива](#%d0%9f%d1%80%d0%be%d0%b2%d0%b5%d1%80%d0%ba%d0%b0-%d0%bc%d0%b0%d1%81%d1%81%d0%b8%d0%b2%d0%b0) + - [Преобразование массива в строку](#%d0%9f%d1%80%d0%b5%d0%be%d0%b1%d1%80%d0%b0%d0%b7%d0%be%d0%b2%d0%b0%d0%bd%d0%b8%d0%b5-%d0%bc%d0%b0%d1%81%d1%81%d0%b8%d0%b2%d0%b0-%d0%b2-%d1%81%d1%82%d1%80%d0%be%d0%ba%d1%83) + - [Объединение элементов массива](#%d0%9e%d0%b1%d1%8a%d0%b5%d0%b4%d0%b8%d0%bd%d0%b5%d0%bd%d0%b8%d0%b5-%d1%8d%d0%bb%d0%b5%d0%bc%d0%b5%d0%bd%d1%82%d0%be%d0%b2-%d0%bc%d0%b0%d1%81%d1%81%d0%b8%d0%b2%d0%b0) + - [Элементы массива срезов](#%d0%ad%d0%bb%d0%b5%d0%bc%d0%b5%d0%bd%d1%82%d1%8b-%d0%bc%d0%b0%d1%81%d1%81%d0%b8%d0%b2%d0%b0-%d1%81%d1%80%d0%b5%d0%b7%d0%be%d0%b2) + - [Метод сращивания в массиве](#%d0%9c%d0%b5%d1%82%d0%be%d0%b4-%d1%81%d1%80%d0%b0%d1%89%d0%b8%d0%b2%d0%b0%d0%bd%d0%b8%d1%8f-%d0%b2-%d0%bc%d0%b0%d1%81%d1%81%d0%b8%d0%b2%d0%b5) + - [Добавление элемента в массив с помощью push](#%d0%94%d0%be%d0%b1%d0%b0%d0%b2%d0%bb%d0%b5%d0%bd%d0%b8%d0%b5-%d1%8d%d0%bb%d0%b5%d0%bc%d0%b5%d0%bd%d1%82%d0%b0-%d0%b2-%d0%bc%d0%b0%d1%81%d1%81%d0%b8%d0%b2-%d1%81-%d0%bf%d0%be%d0%bc%d0%be%d1%89%d1%8c%d1%8e-push) + - [Удаление конечного элемента с помощью pop](#%d0%a3%d0%b4%d0%b0%d0%bb%d0%b5%d0%bd%d0%b8%d0%b5-%d0%ba%d0%be%d0%bd%d0%b5%d1%87%d0%bd%d0%be%d0%b3%d0%be-%d1%8d%d0%bb%d0%b5%d0%bc%d0%b5%d0%bd%d1%82%d0%b0-%d1%81-%d0%bf%d0%be%d0%bc%d0%be%d1%89%d1%8c%d1%8e-pop) + - [Удаление элемента с самого начала](#%d0%a3%d0%b4%d0%b0%d0%bb%d0%b5%d0%bd%d0%b8%d0%b5-%d1%8d%d0%bb%d0%b5%d0%bc%d0%b5%d0%bd%d1%82%d0%b0-%d1%81-%d1%81%d0%b0%d0%bc%d0%be%d0%b3%d0%be-%d0%bd%d0%b0%d1%87%d0%b0%d0%bb%d0%b0) + - [Добавить элемент с начала](#%d0%94%d0%be%d0%b1%d0%b0%d0%b2%d0%b8%d1%82%d1%8c-%d1%8d%d0%bb%d0%b5%d0%bc%d0%b5%d0%bd%d1%82-%d1%81-%d0%bd%d0%b0%d1%87%d0%b0%d0%bb%d0%b0) + - [Обратный порядок массивов](#%d0%9e%d0%b1%d1%80%d0%b0%d1%82%d0%bd%d1%8b%d0%b9-%d0%bf%d0%be%d1%80%d1%8f%d0%b4%d0%be%d0%ba-%d0%bc%d0%b0%d1%81%d1%81%d0%b8%d0%b2%d0%be%d0%b2) + - [Сортировка элементов в массиве](#%d0%a1%d0%be%d1%80%d1%82%d0%b8%d1%80%d0%be%d0%b2%d0%ba%d0%b0-%d1%8d%d0%bb%d0%b5%d0%bc%d0%b5%d0%bd%d1%82%d0%be%d0%b2-%d0%b2-%d0%bc%d0%b0%d1%81%d1%81%d0%b8%d0%b2%d0%b5) + - [Массив массивов](#%d0%9c%d0%b0%d1%81%d1%81%d0%b8%d0%b2-%d0%bc%d0%b0%d1%81%d1%81%d0%b8%d0%b2%d0%be%d0%b2) + - [💻 Упражнения](#%f0%9f%92%bb-%d0%a3%d0%bf%d1%80%d0%b0%d0%b6%d0%bd%d0%b5%d0%bd%d0%b8%d1%8f) + - [Упражнения: Уровень 1](#%d0%a3%d0%bf%d1%80%d0%b0%d0%b6%d0%bd%d0%b5%d0%bd%d0%b8%d1%8f-%d0%a3%d1%80%d0%be%d0%b2%d0%b5%d0%bd%d1%8c-1) + - [Упражнения: Уровень 2](#%d0%a3%d0%bf%d1%80%d0%b0%d0%b6%d0%bd%d0%b5%d0%bd%d0%b8%d1%8f-%d0%a3%d1%80%d0%be%d0%b2%d0%b5%d0%bd%d1%8c-2) + - [Упражнения: Уровень 3](#%d0%a3%d0%bf%d1%80%d0%b0%d0%b6%d0%bd%d0%b5%d0%bd%d0%b8%d1%8f-%d0%a3%d1%80%d0%be%d0%b2%d0%b5%d0%bd%d1%8c-3) + +# 📔 День 5 + +## Массивы + +В отличие от переменных, массив может хранить _несколько значений_. Каждое значение в массиве имеет _индекс_, а каждый индекс имеет _ссылку в адресе памяти_. Каждое значение может быть доступно с помощью их _индексов_. Индекс массива начинается с _0_, а последний элемент на единицу меньше длины массива. + +Массив - это коллекция различных типов данных, которые упорядочены и изменяемы (модифицируемы). Массив позволяет хранить повторяющиеся элементы и различные типы данных. Массив может быть пустым или иметь разные значения типа данных. + +### Как создать пустой массив + +В JavaScript мы можем создать массив различными способами. Давайте по-разному создадим массив. +Очень часто используется _const_ вместо _let_ для объявления переменной массива. Если вы используете `const`, это означает, что вы больше не используете это имя. + +- Используя конструктор Array + +```js +// синтаксис +const arr = Array(); +// or +// let arr = new Array() +console.log(arr); // [] +``` + +- Используя квадратные скобки ([]) + +```js +// синтаксис +// Это наиболее рекомендуемый способ создания пустого списка +const arr = []; +console.log(arr); +``` + +### Как создать массив со значениями + +Массив с начальными значениями. Мы используем свойство _length_, чтобы найти длину массива. + +```js +const numbers = [0, 3.14, 9.81, 37, 98.6, 100]; // массив из чисел +const fruits = ["banana", "orange", "mango", "lemon"]; // массив из строк, fruits +const vegetables = ["Tomato", "Potato", "Cabbage", "Onion", "Carrot"]; // массив из строк, vegetables +const animalProducts = ["milk", "meat", "butter", "yoghurt"]; // массив из строк, products +const webTechs = ["HTML", "CSS", "JS", "React", "Redux", "Node", "MongDB"]; // массив из веб технологий +const countries = ["Finland", "Denmark", "Sweden", "Norway", "Iceland"]; // массив из строк, countries + +// Распечатать массив и его длину + +console.log("Numbers:", numbers); +console.log("Number of numbers:", numbers.length); + +console.log("Fruits:", fruits); +console.log("Number of fruits:", fruits.length); + +console.log("Vegetables:", vegetables); +console.log("Number of vegetables:", vegetables.length); + +console.log("Animal products:", animalProducts); +console.log("Number of animal products:", animalProducts.length); + +console.log("Web technologies:", webTechs); +console.log("Number of web technologies:", webTechs.length); + +console.log("Countries:", countries); +console.log("Number of countries:", countries.length); +``` + +```sh +Numbers: [0, 3.14, 9.81, 37, 98.6, 100] +Number of numbers: 6 +Fruits: ['banana', 'orange', 'mango', 'lemon'] +Number of fruits: 4 +Vegetables: ['Tomato', 'Potato', 'Cabbage', 'Onion', 'Carrot'] +Number of vegetables: 5 +Animal products: ['milk', 'meat', 'butter', 'yoghurt'] +Number of animal products: 4 +Web technologies: ['HTML', 'CSS', 'JS', 'React', 'Redux', 'Node', 'MongDB'] +Number of web technologies: 7 +Countries: ['Finland', 'Estonia', 'Denmark', 'Sweden', 'Norway'] +Number of countries: 5 +``` + +- Массив может иметь элементы разных типов данных + +```js +const arr = [ + "Asabeneh", + 250, + true, + { country: "Finland", city: "Helsinki" }, + { skills: ["HTML", "CSS", "JS", "React", "Python"] } +]; // arr содержит разные типы данных +console.log(arr); +``` + +### Создание массива с использованием split + +Как мы видели в предыдущем разделе, мы можем разбить строку в разных позициях и перейти в массив. Давайте посмотрим на примеры ниже. + +```js +let js = "JavaScript"; +const charsInJavaScript = js.split(""); + +console.log(charsInJavaScript); // ["J", "a", "v", "a", "S", "c", "r", "i", "p", "t"] + +let companiesString = "Facebook, Google, Microsoft, Apple, IBM, Oracle, Amazon"; +const companies = companiesString.split(","); + +console.log(companies); // ["Facebook", " Google", " Microsoft", " Apple", " IBM", " Oracle", " Amazon"] +let txt = + "I love teaching and empowering people. I teach HTML, CSS, JS, React, Python."; +const words = txt.split(" "); + +console.log(words); +// в тексте есть специальные символы, подумайте, как можно получить только слова +// ["I", "love", "teaching", "and", "empowering", "people.", "I", "teach", "HTML,", "CSS,", "JS,", "React,", "Python"] +``` + +### Доступ к элементам массива по индексу + +Мы получаем доступ к каждому элементу в массиве, используя их индекс. Индекс массива начинается с 0. На рисунке ниже четко показано начало индекса. + +![arr index](../images/array_index.png) + +```js +const fruits = ["banana", "orange", "mango", "lemon"]; +let firstFruit = fruits[0]; // мы получаем доступ к первому элементу, используя его индекс + +console.log(firstFruit); // banana + +secondFruit = fruits[1]; +console.log(secondFruit); // orange + +let lastFruit = fruits[3]; +console.log(lastFruit); // lemon +// Последний индекс можно рассчитать следующим образом + +let lastIndex = fruits.length - 1; +lastFruit = fruits[lastIndex]; + +console.log(lastFruit); // lemon +``` + +```js +const numbers = [0, 3.14, 9.81, 37, 98.6, 100]; // набор чисел + +console.log(numbers.length); // => узнать размер массива, который 6 +console.log(numbers); // -> [0, 3.14, 9.81, 37, 98.6, 100] +console.log(numbers[0]); // -> 0 +console.log(numbers[5]); // -> 100 + +let lastIndex = numbers.length - 1; +console.log(numbers[lastIndex]); // -> 100 +``` + +```js +const webTechs = [ + "HTML", + "CSS", + "JavaScript", + "React", + "Redux", + "Node", + "MongoDB" +]; // Список веб-технологий + +console.log(webTechs); // все элементы массива +console.log(webTechs.length); // => узнать размер массива, который 7 +console.log(webTechs[0]); // -> HTML +console.log(webTechs[6]); // -> MongoDB + +let lastIndex = webTechs.length - 1; +console.log(webTechs[lastIndex]); // -> MongoDB +``` + +```js +const countries = [ + "Albania", + "Bolivia", + "Canada", + "Denmark", + "Ethiopia", + "Finland", + "Germany", + "Hungary", + "Ireland", + "Japan", + "Kenya" +]; // Список стран + +console.log(countries); // -> все страны в масиве +console.log(countries[0]); // -> Albania +console.log(countries[10]); // -> Kenya + +let lastIndex = countries.length - 1; +console.log(countries[lastIndex]); // -> Kenya +``` + +```js +const shoppingCart = [ + "Milk", + "Mango", + "Tomato", + "Potato", + "Avocado", + "Meat", + "Eggs", + "Sugar" +]; // Список продуктов питания + +console.log(shoppingCart); // -> все shoppingCart в массиве +console.log(shoppingCart[0]); // -> Milk +console.log(shoppingCart[7]); // -> Sugar + +let lastIndex = shoppingCart.length - 1; +console.log(shoppingCart[lastIndex]); // -> Sugar +``` + +### Изменение элемента массива + +Массив является изменяемым (модифицируемым). После создания массива мы можем изменить содержимое элементов массива. + +```js +const numbers = [1, 2, 3, 4, 5]; +numbers[0] = 10; // изменение 1 на индекс 0 до 10 +numbers[1] = 20; // изменение 2 на индекс 1 до 20 + +console.log(numbers); // [10, 20, 3, 4, 5] + +const countries = [ + "Albania", + "Bolivia", + "Canada", + "Denmark", + "Ethiopia", + "Finland", + "Germany", + "Hungary", + "Ireland", + "Japan", + "Kenya" +]; + +countries[0] = "Afghanistan"; // Замена Albania на Afghanistan +let lastIndex = countries.length - 1; +countries[lastIndex] = "Korea"; // Замена Kenya на Korea + +console.log(countries); +``` + +```sh +["Afghanistan", "Bolivia", "Canada", "Denmark", "Ethiopia", "Finland", "Germany", "Hungary", "Ireland", "Japan", "Korea"] +``` + +### Методы манипулирования массивом + +Существуют разные методы манипулирования массивом. Вот некоторые из доступных методов для работы с массивами: _Array, length, concat, indexOf, slice, splice, join, toString, includes, lastIndexOf, isArray, fill, push, pop, shift, unshift_ + +#### Конструктор массива + +Массив: для создания массива. + +```js +const arr = Array(); // создает пустой массив +console.log(arr); + +const eightEmptyValues = Array(8); // он создает восемь пустых значений +console.log(eightEmptyValues); // [empty x 8] +``` + +#### Creating static values with fill + +fill: Fill all the array elements with a static value + +```js +const arr = Array(); // создает пустой массив +console.log(arr); + +const eightXvalues = Array(8).fill("X"); // он создает восемь значений элементов, заполненных 'X' +console.log(eightXvalues); // ['X', 'X','X','X','X','X','X','X'] + +const eight0values = Array(8).fill(0); // он создает восемь значений элементов, заполненных '0' +console.log(eight0values); // [0, 0, 0, 0, 0, 0, 0, 0] + +const four4values = Array(4).fill(4); // он создает 4 значения элемента, заполненные '4' +console.log(four4values); // [4, 4, 4, 4] +``` + +#### Конкатенация массива с использованием concat + +`concat`: объединение двух массивов. + +```js +const firstList = [1, 2, 3]; +const secondList = [4, 5, 6]; +const thirdList = firstList.concat(secondList); + +console.log(thirdList); // [1, 2, 3, 4, 5, 6] +``` + +```js +const fruits = ["banana", "orange", "mango", "lemon"]; // массив из fruits +const vegetables = ["Tomato", "Potato", "Cabbage", "Onion", "Carrot"]; // массив из vegetables +const fruitsAndVegetables = fruits.concat(vegetables); // объединение двух массивов + +console.log(fruitsAndVegetables); +``` + +```sh +["banana", "orange", "mango", "lemon", "Tomato", "Potato", "Cabbage", "Onion", "Carrot"] +``` + +#### Получение длины массива + +`length`: чтобы узнать размер массива + +```js +const numbers = [1, 2, 3, 4, 5]; +console.log(numbers.length); // -> 5 это размер массива +``` + +#### Получение индекса элемента в массиве arr + +`indexOf`: проверить, существует ли элемент в массиве. Если он существует, он возвращает индекс, иначе он возвращает -1. + +```js +const numbers = [1, 2, 3, 4, 5]; + +console.log(numbers.indexOf(5)); // -> 4 +console.log(numbers.indexOf(0)); // -> -1 +console.log(numbers.indexOf(1)); // -> 0 +console.log(numbers.indexOf(6)); // -> -1 +``` + +Проверьте элемент, если он существует в массиве. + +- Проверьте элементы в списке + +```js +// давайте проверим, существует ли banana в массиве + +const fruits = ["banana", "orange", "mango", "lemon"]; +let index = fruits.indexOf("banana"); // 0 + +if (index != -1) { + console.log("Этот фрукт существует в массиве"); +} else { + console.log("Этот фрукт не существует в массиве"); +} +// Этот фрукт существует в массиве + +// мы можем использовать также тернарный оператор здесь +index != -1 + ? console.log("Этот фрукт существует в массиве") + : console.log("Этот фрукт не существует в массиве"); + +// давайте проверим, существует ли в массиве avocado +let indexOfAvocado = fruits.indexOf("avocado"); // -1, если элемент не найден, индекс -1 +if (indexOfAvocado != -1) { + console.log("Этот фрукт существует в массиве"); +} else { + console.log("Этот фрукт не существует в массиве"); +} +// Этот фрукт не существует в массиве +``` + +#### Получение последнего индекса элемента в массиве + +`lastIndexOf`: отдает позицию последнего элемента в массиве. Если он существует, он возвращает индекс, иначе он возвращает -1. + +```js +const numbers = [1, 2, 3, 4, 5, 3, 1, 2]; + +console.log(numbers.lastIndexOf(2)); // 7 +console.log(numbers.lastIndexOf(0)); // -1 +console.log(numbers.lastIndexOf(1)); // 6 +console.log(numbers.lastIndexOf(4)); // 3 +console.log(numbers.lastIndexOf(6)); // -1 +``` + +`includes` в себя: чтобы проверить, существует ли элемент в массиве. Если он существует, он возвращает истину, иначе он возвращает ложь. + +```js +const numbers = [1, 2, 3, 4, 5]; + +console.log(numbers.includes(5)); // true +console.log(numbers.includes(0)); // false +console.log(numbers.includes(1)); // true +console.log(numbers.includes(6)); // false + +const webTechs = [ + "HTML", + "CSS", + "JavaScript", + "React", + "Redux", + "Node", + "MongoDB" +]; // Список веб-технологий + +console.log(webTechs.includes("Node")); // true +console.log(webTechs.includes("C")); // false +``` + +#### Проверка массива + +`Array.isArray`: чтобы проверить, является ли тип данных массивом + +```js +const numbers = [1, 2, 3, 4, 5]; +console.log(Array.isArray(numbers)); // true + +const number = 100; +console.log(Array.isArray(number)); // false +``` + +#### Преобразование массива в строку + +`toString`: преобразовывает массив в строку + +```js +const numbers = [1, 2, 3, 4, 5]; +console.log(numbers.toString()); // 1,2,3,4,5 + +const names = ["Asabeneh", "Mathias", "Elias", "Brook"]; +console.log(names.toString()); // Asabeneh,Mathias,Elias,Brook +``` + +#### Объединение элементов массива + +`join`: используется для соединения элементов массива, аргумент, переданный в методе join, будет объединен в массив и возвращен в виде строки. По умолчанию он соединяется запятой, но мы можем передать другой строковый параметр, который можно объединить между элементами. + +```js +const numbers = [1, 2, 3, 4, 5]; +console.log(numbers.join()); // 1,2,3,4,5 + +const names = ["Asabeneh", "Mathias", "Elias", "Brook"]; + +console.log(names.join()); // Asabeneh,Mathias,Elias,Brook +console.log(names.join("")); //AsabenehMathiasEliasBrook +console.log(names.join(" ")); //Asabeneh Mathias Elias Brook +console.log(names.join(", ")); //Asabeneh, Mathias, Elias, Brook +console.log(names.join(" # ")); //Asabeneh # Mathias # Elias # Brook + +const webTechs = [ + "HTML", + "CSS", + "JavaScript", + "React", + "Redux", + "Node", + "MongoDB" +]; // Список веб-технологий + +console.log(webTechs.join()); // "HTML,CSS,JavaScript,React,Redux,Node,MongoDB" +console.log(webTechs.join(" # ")); // "HTML # CSS # JavaScript # React # Redux # Node # MongoDB" +``` + +#### Элементы массива срезов + +`slice`: вырезает несколько предметов из диапазона. +Требуется два параметра: начальная и конечная позиция. Это не включает в себя конечную позицию. + +```js +const numbers = [1, 2, 3, 4, 5]; + +console.log(numbers.slice()); // -> it copies all item +console.log(numbers.slice(0)); // -> it copies all item +console.log(numbers.slice(0, numbers.length)); // it copies all item +console.log(numbers.slice(1, 4)); // -> [2,3,4] // it doesn't include the ending position +``` + +#### Метод сращивания в массиве + +`splice`: требуется три параметра: начальная позиция, количество удалений и количество добавляемых элементов. + +```js +const numbers = [1, 2, 3, 4, 5]; + +console.log(numbers.splice()); // -> удалить все предметы +``` + +```js +const numbers = [1, 2, 3, 4, 5]; +console.log(numbers.splice(0, 1)); // удалить первый элемент +``` + +```js +const numbers = [1, 2, 3, 4, 5]; +console.log(numbers.splice(3, 3, 6, 7, 8)); // -> [1, 2, 3, 6, 7, 8] // удаляет два элемента и заменяет три +``` + +#### Добавление элемента в массив с помощью push + +`push`: добавление элемента в конце. Чтобы добавить элемент в конец существующего массива, мы используем метод `push`. + +```js +// синтаксис +const arr = ["item1", "item2", "item3"]; +arr.push("new item"); + +console.log(arr); +// ['item1', 'item2','item3','new item'] +``` + +```js +const numbers = [1, 2, 3, 4, 5]; +numbers.push(6); + +console.log(numbers); // -> [1,2,3,4,5,6] + +numbers.pop(); // -> убрать один предмет с конца +console.log(numbers); // -> [1,2,3,4,5] +``` + +```js +let fruits = ["banana", "orange", "mango", "lemon"]; +fruits.push("apple"); + +console.log(fruits); // ['banana', 'orange', 'mango', 'lemon', 'apple'] + +fruits.push("lime"); +console.log(fruits); // ['banana', 'orange', 'mango', 'lemon', 'apple', 'lime'] +``` + +#### Удаление конечного элемента с помощью pop + +`pop`: удаление элемента в конце. + +```js +const numbers = [1, 2, 3, 4, 5]; +numbers.pop(); // -> убрать один предмет с конца + +console.log(numbers); // -> [1,2,3,4] +``` + +#### Удаление элемента с самого начала + +`shift`: удаление одного элемента массива в начале массива. + +```js +const numbers = [1, 2, 3, 4, 5]; +numbers.shift(); // -> удаление одного элемента с начала + +console.log(numbers); // -> [2,3,4,5] +``` + +#### Добавить элемент с начала + +`unshift`: добавление элемента массива в начало массива. + +```js +const numbers = [1, 2, 3, 4, 5]; +numbers.unshift(0); // -> добавить один элемент с начала + +console.log(numbers); // -> [0,1,2,3,4,5] +``` + +#### Обратный порядок массивов + +`reverse`: обратный порядок массива. + +```js +const numbers = [1, 2, 3, 4, 5]; +numbers.reverse(); // -> обратный порядок массива + +console.log(numbers); // [5, 4, 3, 2, 1] + +numbers.reverse(); +console.log(numbers); // [1, 2, 3, 4, 5] +``` + +#### Сортировка элементов в массиве + +`sort`: расположить элементы массива в порядке возрастания. Сортировка принимает функцию обратного вызова, мы увидим, как мы используем сортировку с функцией обратного вызова в следующих разделах. + +```js +const webTechs = [ + "HTML", + "CSS", + "JavaScript", + "React", + "Redux", + "Node", + "MongoDB" +]; + +webTechs.sort(); +console.log(webTechs); // ["CSS", "HTML", "JavaScript", "MongoDB", "Node", "React", "Redux"] + +webTechs.reverse(); // после сортировки мы можем изменить это +console.log(webTechs); // ["Redux", "React", "Node", "MongoDB", "JavaScript", "HTML", "CSS"] +``` + +### Массив массивов + +Массив может хранить различные типы данных, включая сам массив. Давайте создадим массив массивов + +```js +const firstNums = [1, 2, 3]; +const secondNums = [1, 4, 9]; + +const arrayOfArray = [ + [1, 2, 3], + [1, 2, 3] +]; +console.log(arrayOfArray[0]); // [1, 2, 3] + +const frontEnd = ["HTML", "CSS", "JS", "React", "Redux"]; +const backEnd = ["Node", "Express", "MongoDB"]; +const fullStack = [frontEnd, backEnd]; +console.log(fullStack); // [["HTML", "CSS", "JS", "React", "Redux"], ["Node", "Express", "MongoDB"]] +console.log(fullStack.length); // 2 +console.log(fullStack[0]); // ["HTML", "CSS", "JS", "React", "Redux"] +console.log(fullStack[1]); // ["Node", "Express", "MongoDB"] +``` + +🌕Вы прилежны, и вы уже многого достигли. Вы только что завершили 5-й день испытаний, и вы на 5 шагов приблизились к своему пути к успеху. Теперь сделайте несколько упражнений для вашего мозга и ваших мышц. + +## 💻 Упражнения + +### Упражнения: Уровень 1 + +```js +const countries = [ + "Albania", + "Bolivia", + "Canada", + "Denmark", + "Ethiopia", + "Finland", + "Germany", + "Hungary", + "Ireland", + "Japan", + "Kenya" +]; + +const webTechs = [ + "HTML", + "CSS", + "JavaScript", + "React", + "Redux", + "Node", + "MongoDB" +]; +``` + +1. Объявите массив _empty_; +2. Объявить массив с более чем 5 количеством элементов +3. Найдите длину вашего массива +4. Получить первый элемент, средний элемент и последний элемент массива +5. Объявите массив с именем _mixedDataTypes_, поместите различные типы данных в ваш массив и найдите длину массива. Вы должны быть размером больше 5 +6. Объявите имя переменной массива _itCompanies_ и присвойте начальные значения Facebook, Google, Microsoft, Apple, IBM, Oracle и Amazon +7. Напечатайте массив, используя `console.log()` +8. Распечатайте количество компаний в массиве +9. Распечатать первую компанию, среднюю и последнюю компанию +10. Распечатайте каждую компанию +11. Измените название каждой компании на заглавные по одному и напечатайте их +12. Распечатайте массив как предложение: Facebook, Google, Microsoft, Apple, IBM, Oracle и Amazon являются крупными ИТ-компаниями. +13. Проверьте, существует ли определенная компания в массиве _itCompanies_. Если она существует, верните компанию, иначе верните компанию, которая не найдена +14. Отфильтруйте компании, которые имеют более одного «o» без метода фильтра +15. Сортировать массив с помощью метода `sort()` +16. Обратный массив, используя метод `reverse()` +17. Вырежьте первые 3 компании из массива +18. Вырежьте последние 3 компании из массива +19. Вырежьте середину ИТ-компании или компаний из массива +20. Удалить первую IT-компанию из массива +21. Уберите среднюю ИТ-компанию или компании из массива +22. Удалить последнюю ИТ-компанию из массива +23. Удалить все ИТ-компании + +### Упражнения: Уровень 2 + +1. Создайте отдельный файл _country.js_ и сохраните массив стран в этот файл, создайте отдельный файл _web_techs.js_ и сохраните массив _webTechs_ в этом файле. Доступ к обоим файлам в файле _main.js_ +2. Сначала удалите все функции и измените строку на массив и посчитайте количество слов в массиве + + ```js + let text = + "I love teaching and empowering people. I teach HTML, CSS, JS, React, Python."; + console.log(words); + console.log(words.length); + ``` + + ```sh + ["I", "love", "teaching", "and", "empowering", "people", "I", "teach", "HTML", "CSS", "JS", "React", "Python"] + + 13 + ``` + +3. В следующей корзине добавить, удалить, изменить элементы + + ```js + const shoppingCart = ["Milk", "Coffee", "Tea", "Honey"]; + ``` + + - добавьте 'Meat' в начале вашей корзины, если оно еще не добавлено + - добавьте sugar в конец вашей корзины, если он еще не добавлен + - Удалить 'Honey', если у вас аллергия на мед + - изменить чай на 'Green Tea' + +4. В массиве стран проверьте, существует ли в массиве 'Ethiopia', напечатайте 'Ethiopia'. Если его нет, добавьте в список стран. +5. В массиве webTechs проверьте, существует ли в массиве Sass, и если он существует, выведите «Sass - это препроцесс CSS». Если он не существует, добавьте Sass в массив и распечатайте массив. +6. Объедините следующие две переменные и сохраните их в переменной fullStack. + + ```js + const frontEnd = ["HTML", "CSS", "JS", "React", "Redux"]; + const backEnd = ["Node", "Express", "MongoDB"]; + + console.log(fullStack); + ``` + + ```sh + ["HTML", "CSS", "JS", "React", "Redux", "Node", "Express", "MongoDB"] + ``` + +### Упражнения: Уровень 3 + +1. Ниже приведен массив из 10 студентов в возрасте: + + ```js + const ages = [19, 22, 19, 24, 20, 25, 26, 24, 25, 24]; + ``` + + - Отсортировать массив и найти минимальный и максимальный возраст + - Найти средний возраст (один средний или два средних, разделенные на два) + - Найти средний возраст (все предметы, поделенные на количество предметов) + - Найти диапазон возрастов (максимум минус мин) + - Сравните значения (минимум - среднее) и (максимум - среднее), используйте метод `abs()` + + 1. Разделите первые десять стран из [массива стран](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) + +2. Найдите среднюю страну (страны) в [массиве стран](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) +3. Разделите массив стран на два равных массива, если он четный. Если массив стран не является четным, еще одна страна для первой половины. + +🎉 ПОЗДРАВЛЯЕМ ! 🎉 + +[<< День 4](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/RU/04_Day/04_day_conditionals.md) | [День 6 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/RU/06_Day/06_day_loops.md) diff --git a/RU/06_Day/06_day_loops.md b/RU/06_Day/06_day_loops.md new file mode 100644 index 0000000..3308eb4 --- /dev/null +++ b/RU/06_Day/06_day_loops.md @@ -0,0 +1,443 @@ +
    +

    30 Days Of JavaScript

    + + + + + Twitter Follow + + +Автор: +Asabeneh Yetayeh
    + Январь, 2020 +
    + +
    + +[<< День 5](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/RU/05_Day/05_day_arrays.md) | [День 7 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/RU/07_Day/07_day_functions.md) + +![Day 5](../images/banners/day_1_6.png) + +- [📔 День 6](#%f0%9f%93%94-%d0%94%d0%b5%d0%bd%d1%8c-6) + - [Циклы](#%d0%a6%d0%b8%d0%ba%d0%bb%d1%8b) + - [Цикл for](#%d0%a6%d0%b8%d0%ba%d0%bb-for) + - [Цикл while](#%d0%a6%d0%b8%d0%ba%d0%bb-while) + - [Цикл do while](#%d0%a6%d0%b8%d0%ba%d0%bb-do-while) + - [Цикл for of](#%d0%a6%d0%b8%d0%ba%d0%bb-for-of) + - [break](#break) + - [continue](#continue) + - [💻 Упражнения: День 6](#%f0%9f%92%bb-%d0%a3%d0%bf%d1%80%d0%b0%d0%b6%d0%bd%d0%b5%d0%bd%d0%b8%d1%8f-%d0%94%d0%b5%d0%bd%d1%8c-6) + - [Упражнения: Уровень 1](#%d0%a3%d0%bf%d1%80%d0%b0%d0%b6%d0%bd%d0%b5%d0%bd%d0%b8%d1%8f-%d0%a3%d1%80%d0%be%d0%b2%d0%b5%d0%bd%d1%8c-1) + - [Упражнения: Уровень 2](#%d0%a3%d0%bf%d1%80%d0%b0%d0%b6%d0%bd%d0%b5%d0%bd%d0%b8%d1%8f-%d0%a3%d1%80%d0%be%d0%b2%d0%b5%d0%bd%d1%8c-2) + - [Упражнения: Уровень 3](#%d0%a3%d0%bf%d1%80%d0%b0%d0%b6%d0%bd%d0%b5%d0%bd%d0%b8%d1%8f-%d0%a3%d1%80%d0%be%d0%b2%d0%b5%d0%bd%d1%8c-3) + +# 📔 День 6 + +## Циклы + +Большинство действий, которые мы делаем в жизни, полны повторений. Представьте себе, если я попрошу вас распечатать от 0 до 100, используя `console.log()`. Для реализации этой простой задачи может потребоваться от 2 до 5 минут, такая утомительная и повторяющаяся задача может быть выполнена с помощью цикла. + +В языках программирования для выполнения повторяющихся задач мы используем разные виды циклов. Следующие примеры представляют собой наиболее часто используемые циклы. + +### Цикл for + +```js +// Структура цикла for +for(initialization, condition, increment/decrement){ + // код идет здесь +} +``` + +```js +for (let i = 0; i <= 5; i++) { + console.log(i); +} +// 0 1 2 3 4 5 +``` + +```js +for (let i = 5; i >= 0; i--) { + console.log(i); +} +// 5 4 3 2 1 0 +``` + +```js +for (let i = 0; i <= 5; i++) { + console.log(`${i} * ${i} = ${i * i}`); +} +``` + +```sh +0 * 0 = 0 +1 * 1 = 1 +2 * 2 = 4 +3 * 3 = 9 +4 * 4 = 16 +5 * 5 = 25 +``` + +```js +const countries = ["Finland", "Sweden", "Denmark", "Norway", "Iceland"]; +const newArr = []; +for (let i = 0; i < countries.length; i++) { + newArr.push(countries[i].toUpperCase()); +} +//["FINLAND", "SWEDEN", "DENMARK", "NORWAY", "ICELAND"] +``` + +Добавление всех элементов в массив + +```js +const numbers = [1, 2, 3, 4, 5]; +let sum = 0; +for (let i = 0; i < numbers.length; i++) { + sum = sum + numbers[i]; // можно сократить: sum += numbers[i] +} + +console.log(sum); // 15 +``` + +Создание нового массива на основе существующего массива + +```js +const numbers = [1, 2, 3, 4, 5]; +const newArr = []; +let sum = 0; +for (let i = 0; i < numbers.length; i++) { + newArr.push(i * i); +} + +console.log(newArr); // [1, 4, 9, 16, 25] +``` + +```js +const countries = ["Finland", "Sweden", "Norway", "Denmark", "Iceland"]; +const newArr = []; +for (let i = 0; i < countries.length; i++) { + newArr.push(countries[i].toUpperCase()); +} + +console.log(newArr); // ["FINLAND", "SWEDEN", "NORWAY", "DENMARK", "ICELAND"] +``` + +### Цикл while + +```js +let i = 0; +while (i <= 5) { + console.log(i); + i++; +} +// 0 1 2 3 4 5 +``` + +### Цикл do while + +```js +let i = 0; +do { + console.log(i); + i++; +} while (i <= 5); +// 0 1 2 3 4 5 +``` + +### Цикл for of + +Мы используем для цикла для массивов. Это очень удобный способ перебора массива, если мы не заинтересованы в индексе. + +```js +for (const element of arr) { + // код идет здесь +} +``` + +```js +const numbers = [1, 2, 3, 4, 5]; + +for (const num of numbers) { + console.log(num); //1 2 3 4 5 +} + +for (const num of numbers) { + console.log(num * num); //1 4 9 16 25 +} + +// добавление всех чисел в массиве +let sum = 0; +for (const num of numbers) { + sum += sum + num; // можно также сократить, как это: sum += num +} +console.log(sum); // 15 + +const webTechs = [ + "HTML", + "CSS", + "JavaScript", + "React", + "Redux", + "Node", + "MongoDB" +]; + +for (const tech of webTechs) { + console.log(tech.toUpperCase()); // HTML CSS JAVASCRIPT REACT NODE MONGODB +} + +for (const tech of webTechs) { + console.log(tech[0]); // получить только первую букву каждого элемента, H C J R N M +} +``` + +```js +const countries = ["Finland", "Sweden", "Norway", "Denmark", "Iceland"]; +const newArr = []; +for (const country of countries) { + newArr.push(country.toUpperCase()); +} + +console.log(newArr); // ["FINLAND", "SWEDEN", "NORWAY", "DENMARK", "ICELAND"] +``` + +### break + +контент будет добавлен в ближайшее время + +### continue + +контент будет добавлен в ближайшее время + +🌕 Ты такой смелый, что дошел так далеко. Теперь вы получили возможность автоматизировать повторяющиеся и утомительные задачи. Вы только что завершили 6-й день испытаний, и вы на 6 ступенек на пути к успеху. Теперь сделайте несколько упражнений для вашего мозга и ваших мышц. + +## 💻 Упражнения: День 6 + +### Упражнения: Уровень 1 + +```js +const countries = [ + "Albania", + "Bolivia", + "Canada", + "Denmark", + "Ethiopia", + "Finland", + "Germany", + "Hungary", + "Ireland", + "Japan", + "Kenya" +]; + +const webTechs = [ + "HTML", + "CSS", + "JavaScript", + "React", + "Redux", + "Node", + "MongoDB" +]; + +const mernStack = ["MongoDB", "Express", "React", "Node"]; +``` + +1. Выполните итерацию от 0 до 10 с помощью цикла `for`, сделайте то же самое с помощью циклов `while` и `do while` +2. Итерируйте 10 к 0, используя цикл `for`, cделайте то же самое, используя цикл `while` и `do while` +3. Итерируйте от 0 до n, используя цикл `for` +4. Напишите цикл, который создает следующий шаблон, используя `console.log()`: + + ```js + # + ## + ### + #### + ##### + ###### + ####### + ``` + +5. Используйте цикл для печати следующего шаблона: + + ```sh + 0 x 0 = 0 + 1 x 1 = 1 + 2 x 2 = 4 + 3 x 3 = 9 + 4 x 4 = 16 + 5 x 5 = 25 + 6 x 6 = 36 + 7 x 7 = 49 + 8 x 8 = 64 + 9 x 9 = 81 + 10 x 10 = 100 + ``` + +6. Используя цикл, напечатайте следующий шаблон + + ```sh + i i^2 i^3 + 0 0 0 + 1 1 1 + 2 4 8 + 3 9 27 + 4 16 64 + 5 25 125 + 6 36 216 + 7 49 343 + 8 64 512 + 9 81 729 + 10 100 1000 + ``` + +7. Используйте цикл для перебора от 0 до 100 и печати только четных чисел. +8. Используйте цикл для итерации от 0 до 100 и выведите только нечетные числа +9. Используйте цикл для итерации от 0 до 100 и печатайте только простые числа +10. Используйте цикл для итерации от 0 до 100, распечатайте и распечатайте сумму всех чисел. + + ```sh + Сумма всех чисел 5050. + ``` + +11. Используйте цикл `for` для итерации от 0 до 100 и выведите сумму всех четных чисел и сумму всех коэффициентов. + + ```sh + The sum of all evens is 2550. And the sum of all odds is 2500. + ``` + +12. Используйте цикл `for` для итерации от 0 до 100 и выведите сумму всех четных чисел и сумму всех шансов. Вывести сумму четных и сумму шансов в виде массива + + ```sh + [2550, 2500] + ``` + +13. Разработайте небольшой скрипт, который генерирует массив из 5 случайных чисел +14. Разработайте небольшой скрипт, который генерирует массив из 5 случайных чисел, числа должны быть уникальными +15. Разработайте небольшой скрипт, который генерирует случайный идентификатор из шести символов: + + ```sh + 5j2khz + ``` + +### Упражнения: Уровень 2 + +1. Разработайте небольшой скрипт, который генерирует произвольное количество символов случайного идентификатора: + + ```sh + fe3jo1gl124g + ``` + + ```sh + xkqci4utda1lmbelpkm03rba + ``` + +2. Напишите скрипт, который генерирует случайное шестнадцатеричное число + + ```sh + '#ee33df' + ``` + +3. Напишите скрипт, который генерирует случайное число цветов RGB. + + ```sh + rgb(240,180,80) + ``` + +4. Используя вышеуказанный массив стран, создайте следующий новый массив. + + ```sh + ["ALBANIA", "BOLIVIA", "CANADA", "DENMARK", "ETHIOPIA", "FINLAND", "GERMANY", "HUNGARY", "IRELAND", "JAPAN", "KENYA"] + ``` + +5. Используя приведенный выше массив стран, создайте массив для длины стран. + + ```sh + [7, 7, 6, 7, 8, 7, 7, 7, 7, 5, 5] + ``` + +6. Используйте массив стран для создания следующего массива массивов: + + ```sh + [ + ['Albania', 'ALB', 7], + ['Bolivia', 'BOL', 7], + ['Canada', 'CAN', 6], + ['Denmark', 'DEN', 7], + ['Ethiopia', 'ETH', 8], + ['Finland', 'FIN', 7], + ['Germany', 'GER', 7], + ['Hungary', 'HUN', 7], + ['Ireland', 'IRE', 7], + ['Japan', 'JAP', 5], + ['Kenya', 'KEN', 5] + ] + ``` + +7. В приведенном выше массиве стран проверьте, существует ли страна или страны, содержащие слово 'land'. Если есть страны, содержащие 'land', выведите ее в виде массива. Если нет страны, содержащей слово 'land', выведите «All these are countries without land». + + ```sh + ['Finland', 'Iceland'] + ``` + +8. В приведенном выше массиве стран проверьте, существует ли страна или страны, заканчивающиеся на «ia». Если есть страны, оканчивающиеся на, распечатайте его, как массив. Если нет страны, содержащей слово «ai», выведите «Эти страны заканчиваются без ia». + + ```sh + ['Albania', 'Bolivia','Ethiopia'] + ``` + +9. Используя приведенный выше массив стран, найдите страну, содержащую наибольшее количество символов. + + ```sh + Ethiopia + ``` + +10. Используя приведенный выше массив стран, найдите страну, содержащую всего 5 символов. + + ```sh + ['Japan', 'Kenya'] + ``` + +11. Найдите самое длинное слово в массиве webTechs. +12. Используйте webTechs для создания следующего массива массивов: + + ```sh + [["HTML", 4], ["CSS", 3],["JavaScript", 10],["React", 5],["Redux", 5],["Node", 4],["MongoDB", 7]] + ``` + +13. Приложение, созданное с использованием MongoDB, Express, React и Node, называется стеком MERN. Создайте аббревиатуру MERN с помощью массива mernStack. +14. Итерируйте по массиву, `["HTML", "CSS", "JS", "React", "Redux", "Node", "Express", "MongoDB"]`, используя цикл `for` или цикл `for of` печатайте из предметов. +15. Это массив фруктов `['banana', 'orange', 'mango', 'lemon']` измените порядок, используя цикл, без использования обратного метода. +16. Распечатайте все элементы массива, как показано ниже. + + ```js + const fullStack = [ + ["HTML", "CSS", "JS", "React"], + ["Node", "Express", "MongoDB"] + ]; + ``` + + ```sh + HTML + CSS + JS + REACT + NODE + EXPRESS + MONGODB + ``` + +### Упражнения: Уровень 3 + +1. Скопируйте массив стран (избегайте мутаций) +2. Массивы изменчивы. Создайте копию массива, которая не изменяет оригинал. Сортировать скопированный массив и сохранить в переменной _sortedCountries_ +3. Отсортируйте массив `webTechs` и массив `mernStack` +4. Извлеките все страны содержащие слово 'land' в [массив стран](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) и распечатайте его как массив +5. Найдите страну, содержащую наибольшее количество символов в [массиве стран](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) +6. Извлеките все страны содержащие слово 'land' from the [массив стран](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) и распечатайте его как массив +7. Извлеките все страны, содержащие только четыре символа из [массива стран](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) и распечатайте его как массив +8. Извлеките все страны, содержащие два или более слов из [массив стран](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) и распечатайте его как массив +9. Разверните [массив стран](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) и примените метод capitalize для каждой страны, храня его в виде массива + +🎉 ПОЗДРАВЛЯЕМ ! 🎉 + +[<< День 5](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/RU/05_Day/05_day_arrays.md) | [День 7 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/RU/07_Day/07_day_functions.md) diff --git a/RU/README.md b/RU/README.md new file mode 100644 index 0000000..ecd2a4d --- /dev/null +++ b/RU/README.md @@ -0,0 +1,623 @@ +
    +

    30 Days Of JavaScript

    + + + + + Twitter Follow + + +Автор: +Asabeneh Yetayeh
    + Январь, 2020 +
    + +
    + + 🇬🇧 [English](../readMe.md) + 🇪🇸 [Spanish](../Spanish/readme.md) + 🇷🇺 [Russian](./README.md) + +
    + +
    + +[День 2 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/RU/02_Day/02_day_data_types.md) + +![Thirty Days Of JavaScript](./images/day_1_1.png) + +- [День 1](#%d0%94%d0%b5%d0%bd%d1%8c-1) + - [Вступление](#%d0%92%d1%81%d1%82%d1%83%d0%bf%d0%bb%d0%b5%d0%bd%d0%b8%d0%b5) + - [Требования](#%d0%a2%d1%80%d0%b5%d0%b1%d0%be%d0%b2%d0%b0%d0%bd%d0%b8%d1%8f) + - [Настройка](#%d0%9d%d0%b0%d1%81%d1%82%d1%80%d0%be%d0%b9%d0%ba%d0%b0) + - [Установка Node.js](#%d0%a3%d1%81%d1%82%d0%b0%d0%bd%d0%be%d0%b2%d0%ba%d0%b0-nodejs) + - [Браузер](#%d0%91%d1%80%d0%b0%d1%83%d0%b7%d0%b5%d1%80) + - [Установка Google Chrome](#%d0%a3%d1%81%d1%82%d0%b0%d0%bd%d0%be%d0%b2%d0%ba%d0%b0-google-chrome) + - [Открытие Google Chrome Console](#%d0%9e%d1%82%d0%ba%d1%80%d1%8b%d1%82%d0%b8%d0%b5-google-chrome-console) + - [Написание кода на консоли браузера](#%d0%9d%d0%b0%d0%bf%d0%b8%d1%81%d0%b0%d0%bd%d0%b8%d0%b5-%d0%ba%d0%be%d0%b4%d0%b0-%d0%bd%d0%b0-%d0%ba%d0%be%d0%bd%d1%81%d0%be%d0%bb%d0%b8-%d0%b1%d1%80%d0%b0%d1%83%d0%b7%d0%b5%d1%80%d0%b0) + - [Console.log](#consolelog) + - [Console.log with multiple arguments](#consolelog-with-multiple-arguments) + - [Комментарии](#%d0%9a%d0%be%d0%bc%d0%bc%d0%b5%d0%bd%d1%82%d0%b0%d1%80%d0%b8%d0%b8) + - [Синтаксис](#%d0%a1%d0%b8%d0%bd%d1%82%d0%b0%d0%ba%d1%81%d0%b8%d1%81) + - [Арифметика](#%d0%90%d1%80%d0%b8%d1%84%d0%bc%d0%b5%d1%82%d0%b8%d0%ba%d0%b0) + - [Редактор кода](#%d0%a0%d0%b5%d0%b4%d0%b0%d0%ba%d1%82%d0%be%d1%80-%d0%ba%d0%be%d0%b4%d0%b0) + - [Установка Visual Studio Code](#%d0%a3%d1%81%d1%82%d0%b0%d0%bd%d0%be%d0%b2%d0%ba%d0%b0-visual-studio-code) + - [Как использовать VS Code](#%d0%9a%d0%b0%d0%ba-%d0%b8%d1%81%d0%bf%d0%be%d0%bb%d1%8c%d0%b7%d0%be%d0%b2%d0%b0%d1%82%d1%8c-vs-code) + - [Добавление JavaScript на веб-страницу](#%d0%94%d0%be%d0%b1%d0%b0%d0%b2%d0%bb%d0%b5%d0%bd%d0%b8%d0%b5-javascript-%d0%bd%d0%b0-%d0%b2%d0%b5%d0%b1-%d1%81%d1%82%d1%80%d0%b0%d0%bd%d0%b8%d1%86%d1%83) + - [Встроенный скрипт](#%d0%92%d1%81%d1%82%d1%80%d0%be%d0%b5%d0%bd%d0%bd%d1%8b%d0%b9-%d1%81%d0%ba%d1%80%d0%b8%d0%bf%d1%82) + - [Внутренний скрипт](#%d0%92%d0%bd%d1%83%d1%82%d1%80%d0%b5%d0%bd%d0%bd%d0%b8%d0%b9-%d1%81%d0%ba%d1%80%d0%b8%d0%bf%d1%82) + - [Внешний скрипт](#%d0%92%d0%bd%d0%b5%d1%88%d0%bd%d0%b8%d0%b9-%d1%81%d0%ba%d1%80%d0%b8%d0%bf%d1%82) + - [Несколько внешних скриптов](#%d0%9d%d0%b5%d1%81%d0%ba%d0%be%d0%bb%d1%8c%d0%ba%d0%be-%d0%b2%d0%bd%d0%b5%d1%88%d0%bd%d0%b8%d1%85-%d1%81%d0%ba%d1%80%d0%b8%d0%bf%d1%82%d0%be%d0%b2) + - [Введение в типы данных](#%d0%92%d0%b2%d0%b5%d0%b4%d0%b5%d0%bd%d0%b8%d0%b5-%d0%b2-%d1%82%d0%b8%d0%bf%d1%8b-%d0%b4%d0%b0%d0%bd%d0%bd%d1%8b%d1%85) + - [Число](#%d0%a7%d0%b8%d1%81%d0%bb%d0%be) + - [Строка](#%d0%a1%d1%82%d1%80%d0%be%d0%ba%d0%b0) + - [Пример](#%d0%9f%d1%80%d0%b8%d0%bc%d0%b5%d1%80) + - [Булевый (логический) тип «boolean»](#%d0%91%d1%83%d0%bb%d0%b5%d0%b2%d1%8b%d0%b9-%d0%bb%d0%be%d0%b3%d0%b8%d1%87%d0%b5%d1%81%d0%ba%d0%b8%d0%b9-%d1%82%d0%b8%d0%bf-%c2%abboolean%c2%bb) + - [Пример](#%d0%9f%d1%80%d0%b8%d0%bc%d0%b5%d1%80-1) + - [Undefined](#undefined) + - [Null](#null) + - [Проверка типов данных](#%d0%9f%d1%80%d0%be%d0%b2%d0%b5%d1%80%d0%ba%d0%b0-%d1%82%d0%b8%d0%bf%d0%be%d0%b2-%d0%b4%d0%b0%d0%bd%d0%bd%d1%8b%d1%85) + - [Комментарии](#%d0%9a%d0%be%d0%bc%d0%bc%d0%b5%d0%bd%d1%82%d0%b0%d1%80%d0%b8%d0%b8-1) + - [Переменные](#%d0%9f%d0%b5%d1%80%d0%b5%d0%bc%d0%b5%d0%bd%d0%bd%d1%8b%d0%b5) + - [Примеры: Переменные](#%d0%9f%d1%80%d0%b8%d0%bc%d0%b5%d1%80%d1%8b-%d0%9f%d0%b5%d1%80%d0%b5%d0%bc%d0%b5%d0%bd%d0%bd%d1%8b%d0%b5) +- [💻 День 1: Упражнения](#%f0%9f%92%bb-%d0%94%d0%b5%d0%bd%d1%8c-1-%d0%a3%d0%bf%d1%80%d0%b0%d0%b6%d0%bd%d0%b5%d0%bd%d0%b8%d1%8f) + +# День 1 + +## Вступление + +**Поздравляем** с решением принять участие в 30-дневном челендже по программированию на JavaScript. В этом задании вы изучите все, что вам нужно для того, чтобы стать программистом на JavaScript, и вообще все концепции программирования. В конце конкурса вы получите сертификат 30DaysOfJavaScript. Присоединяйтесь к [группе телеграмм](https://t.me/ThirtyDaysOfJavaScript). + +**Задача 30DaysOfJavaScript** - руководство для начинающих и опытных разработчиков JavaScript. Добро пожаловать в JavaScript. Мне нравится использовать и преподавать JavaScript, и я надеюсь, что вы это сделаете. JavaScript - это язык браузера. + +В этом пошаговом руководстве вы изучите JavaScript, самый популярный язык программирования в истории человечества. +Вы используете JavaScript **_для добавления интерактивности на веб-сайты, для разработки мобильных приложений, настольных приложений, игр_**, и в настоящее время JavaScript можно использовать для **_машинного обучения_** и **_AI_**. +**_JavaScript (JS)_** вырос в популярности в последние годы и был ведущим языком программирования в течение четырех лет подряд и является наиболее используемым языком программирования на Github. + +## Требования + +Для выполнения этой задачи не требуется предварительное знание программирования. Вам нужно только: + +1. Мотивация +2. Компьютер +3. Интернет +4. Браузер +5. Редактор кода + +## Настройка + +Я считаю, что у вас есть мотивация и сильное желание быть разработчиком, компьютер и Интернет. Если у вас есть это, то у вас есть всё =). + +### Установка Node.js + +Возможно, вам это не нужно прямо сейчас, но может понадобиться позже. Устанавить [node.js](https://nodejs.org/en/). + +![Node download](images/download_node.png) + +После загрузки дважды щелкните и установите + +![Install node](images/install_node.png) + +Мы можем проверить, установлен ли узел на нашем локальном компьютере, открыв терминал устройства или командную строку. + +```sh +asabeneh $ node -v +v12.14.0 +``` + +Я использую версию node 12.14.0, которая является рекомендуемой версией узла. + +### Браузер + +Есть много браузеров там. Тем не менее, я настоятельно рекомендую Google Chrome. + +#### Установка Google Chrome + +Установите [google chrome](https://www.google.com/chrome/), если у вас его еще нет. Мы можем написать небольшой код JavaScript в консоли браузера, но мы не используем консоль браузера для разработки приложений. + +![Google Chrome](images/google_chrome.png) + +#### Открытие Google Chrome Console + +Вы можете открыть Google Chrome, нажав три точки в верхнем правом углу браузера Chrome или воспользовавшись ярлыком. Я предпочитаю использовать ярлыки. + +![Opening chrome](images/opening_developer_tool.png) + +Чтобы открыть консоль Chrome с помощью горячих клавиш. + +```sh +Mac +Command+Option+I + +Windows: +Ctl+Shift+I +``` + +![Opening console](images/opening_chrome_console_shortcut.png) + +После того, как вы откроете консоль Google Chrome, попробуйте изучить отмеченные кнопки. Мы будем проводить большую часть времени на консоли. Консоль - это место, куда идет ваш код JavaScript. Движок Google Console V8 изменяет ваш код JavaScript на машинный код. +Давайте напишем код JavaScript на консоли Google Chrome: + +![write code on console](./images/js_code_on_chrome_console.png) + +#### Написание кода на консоли браузера + +Мы можем написать любой код JavaScript на консоли Google или любой консоли браузера. Однако для решения этой проблемы мы сосредоточимся только на консоли Google Chrome. Откройте консоль, используя: + +```sh +Mac +Command+Option+I + +Windows: +Ctl+Shift+I +``` + +##### Console.log + +Чтобы написать наш первый код JavaScript, мы использовали встроенную функцию `console.log()`. Мы передали аргумент в качестве входных данных, и функция отображает вывод. Мы передали 'Hello, World' в качестве входных данных или аргумента в функцию `console.log()`. + +```js +console.log("Hello, World!"); +``` + +##### Console.log with multiple arguments + +`console.log(param1, param2, param3)`, может принимать несколько аргументов. + +![console log multiple arguments](./images/console_log_multipl_arguments.png) + +```js +console.log("Hello", "World", "!"); +console.log("HAPPY", "NEW", "YEAR", 2020); +console.log("Welcome", "to", 30, "Days", "Of", "JavaScript"); +``` + +Как вы можете видеть из приведенного выше фрагмента кода, `console.log()` может принимать несколько аргументов. + +Поздравляем! Вы написали свой первый код JavaScript, используя `console.log()`. + +##### Комментарии + +Мы добавляем комментарии к нашему коду. Комментарии очень важны, чтобы сделать код более читабельным и оставить комментарии в нашем коде. JavaScript не выполняет часть комментариев нашего кода. Любой текст, начинающийся с `//` в JavaScript, является комментарием или что-то в этом роде `/* */` является комментарием. + +**Пример: Однострочный комментарийt** + +```js +// Это первый комментарий +// Это второй комментарий +// Я однострочный комментарий +``` + +**Пример: Многострочный комментарий** + +```js +/* +Это многострочный комментарий +Многострочные комментарии могут занимать несколько строк +JavaScript - это язык Интернета +*/ +``` + +##### Синтаксис + +JavaScript это язык программирования. В результате он имеет свой синтаксис, как и другие языки программирования. Если мы не напишем синтаксис, понятный JavaScript, это вызовет различные типы ошибок. Мы рассмотрим различные виды ошибок JavaScript позже. А пока давайте посмотрим на синтаксические ошибки. + +![Error](images/raising_syntax_error.png) + +Я сделал преднамеренную ошибку. В результате консоль вызывает синтаксическую ошибку. На самом деле, синтаксис очень информативен. Он сообщает, какую ошибку мы допустили. Прочитав руководство по обратной связи об ошибках, мы можем исправить синтаксис и устранить проблему. Процесс выявления и удаления ошибок из программы называется отладкой. Давайте исправим ошибки: + +```js +console.log("Hello, World!"); +console.log("Hello, World!"); +``` + +До сих пор мы видели, как отображать текст с помощью `console.log()`. Если мы печатаем текст или строку с помощью `console.log()`, текст должен находиться в одинарных, двойных или обратных кавычках. +**Пример:** + +```js +console.log("Hello, World!"); +console.log("Hello, World!"); +console.log(`Hello, World!`); +``` + +#### Арифметика + +Теперь давайте попрактикуемся в написании кодов JavaScript с помощью `console.log()` в консоли Google Chrome для числовых типов данных. +В дополнение к тексту мы также можем выполнять математические вычисления с использованием JavaScript. Давайте сделаем следующие простые вычисления. + +![Arithmetic](images/arithmetic.png) + +```js +console.log(2 + 3); // Сложение +console.log(3 - 2); // Вычитание +console.log(2 * 3); // Умножение +console.log(3 / 2); // Разделение +console.log(3 % 2); // Модуль - поиск остатка +console.log(3 ** 2); // Экспоненциальный +``` + +### Редактор кода + +Мы можем написать наш код в консоли браузера, но это не будет работать для больших проектов. В реальной рабочей среде разработчики используют разные редакторы кода для написания своих кодов. В этом 30-дневном челендже JavaScript мы будем использовать визуальный Visual Studio Code. + +#### Установка Visual Studio Code + +VS Code - это очень популярный текстовый редактор с открытым исходным кодом. Я бы рекомендовал [скачать](https://code.visualstudio.com/) VS Code, но если вы поддерживаете другие редакторы, не стесняйтесь использовать то, что у вас есть. + +![Vscode](images/vscode.png) + +Если вы установили код VS Code, давайте начнем использовать его. + +#### Как использовать VS Code + +Откройте код VS Code, дважды щелкнув значок VS Code. Когда вы откроете его, вы получите такой интерфейс. Попробуйте взаимодействовать с помеченными значками. + +![Vscode ui](./images/vscode_ui.png) + +![Vscode add project](./images/adding_project_to_vscode.png) + +![Vscode open project](./images/opening_project_on_vscode.png) + +![script file](images/scripts_on_vscode.png) + +![running script](./images/running_script.png) + +![coding running](./images/launched_on_new_tab.png) + +## Добавление JavaScript на веб-страницу + +JavaScript можно добавить на веб-страницу тремя различными способами: + +- **_Встроенный скрипт_** +- **_Внутренний скрипт_** +- **_Внешний скрипт_** +- **_Несколько внешних скриптов_** + +В следующих разделах показаны различные способы добавления кода JavaScript на вашу веб-страницу. + +### Встроенный скрипт + +Создайте папку на рабочем столе и назовите ее `30DaysOfJS` или в любом месте и создайте файл **_index.html_** в папке проекта. Затем вставьте следующий код и откройте его в браузере, либо в [Chrome](https://www.google.com/chrome/). + +```html + + + + 30DaysOfScript: Встроенный скрипт + + + + + +``` + +Теперь вы написали свой первый встроенный скрипт. Мы можем создать всплывающее сообщение с предупреждением, используя встроенную функцию `alert()`. + +### Внутренний скрипт + +Внутренний скрипт может быть записан в `head` или `body`, но предпочтительно поместить его в `body` HTML-документа. +Во-первых, давайте напишем в верхней части страницы. + +```html + + + + 30DaysOfScript: Внутренний скрипт + + + + +``` + +Так мы пишем внутренний скрипт большую часть времени. Написание кода JavaScript в разделе `body` является наиболее предпочтительным местом. Откройте консоль браузера, чтобы увидеть вывод `console.log()` + +```html + + + + 30DaysOfScript: Внутренний скрипт + + + + + + +``` + +Откройте консоль браузера, чтобы увидеть вывод `console.log()` + +![js code from vscode](./images/js_code_vscode.png) + +### Внешний скрипт + +Подобно внутреннему сценарию, ссылка на внешний сценарий может быть в `head` или `body`, но предпочтительно помещать ее в `body`. +Во-первых, мы должны создать внешний файл JavaScript с расширением `.js`. Любой файл JavaScript заканчивается на `.js`. Создайте файл `introduction.js` внутри директории вашего проекта, напишите следующий код и подключите этот файл `.js` внизу `body`. + +```js +console.log("Добро пожаловать на 30 дней JavaScript"); +``` + +Внешние скрипты в head + +```html + + + + 30DaysOfJavaScript: Внешний скрипт + + + + +``` + +Внешние скрипты в body + +```html + + + + 30DaysOfJavaScript:External script + + + + + + +``` + +Откройте консоль браузера, чтобы увидеть вывод `console.log()`. + +### Несколько внешних скриптов + +Мы можем связать несколько внешних файлов JavaScript с веб-страницей. +Создайте файл _helloworld.js_ в папке 30DaysOfJS и напишите следующий код. + +```js +console.log("Hello, World!"); +``` + +```html + + + + Multiple External Scripts + + + + + + +``` + +Ваш файл main.js должен быть ниже всех других скриптов. Будьте внимательными, чтобы понять эту строчку. + +![Multiple Script](./images/multiple_script.png) + +## Введение в типы данных + +В JavaScript, а также в других языках программирования существуют разные типы типов данных. Ниже приведены примитивные типы данных JavaScript: _Строка, Число, Булевый (логический) тип, undefined, Null_ и _Symbol_. + +### Число + +- Integer: Целые (отрицательные, нулевые и положительные) числа + Пример: + ... -3, -2, -1, 0, 1, 2, 3 ... +- Float: десятичное число + Пример: + ... -3.5, -2.25, -1.0, 0.0, 1.1, 2.2, 3.5 ... + +### Строка + +Строка (string) в JavaScript должна быть заключена в кавычки (одинарных, двойных или обратных кавычках). + +#### Пример + +```js +"Asabeneh"; +"Finland"; +"JavaScript is a beautiful programming language"; +"I love teaching"; +"I hope you are enjoying the first day"`We can also create a string using a backtick`; +``` + +### Булевый (логический) тип «boolean» + +Логическое значение может быть истинным или ложным. Любые сравнения возвращают логическое значение, которое является истинным или ложным. + +Логический тип данных является либо Истинным, либо Ложным значением. + +#### Пример + +```js +true; // если свет включен, значение истинно +false; // если свет выключен, значение False +``` + +### Undefined + +В JavaScript, если мы не присваиваем значение переменной, значение не определено. В дополнение к этому, если функция ничего не возвращает, она возвращает undefined. + +```js +let firstName; +console.log(firstName); // не определено, потому что оно еще не присвоено значению +``` + +### Null + +Null в JavaScript означает пустое значение. + +```js +let emptyValue = null; +``` + +## Проверка типов данных + +Чтобы проверить тип данных определенного типа данных, мы используем оператор `typeof`. Смотрите следующий пример. + +```js +console.log(typeof "Asabeneh"); // строка +console.log(typeof 5); // число +console.log(typeof true); // булевое значение +console.log(typeof null); // объект +console.log(typeof undefined); // undefined +``` + +## Комментарии + +Комментирование в JavaScript похоже на другие языки программирования. Комментарии важны для того, чтобы сделать ваш код более читабельным. + +Есть два способа комментирования: + +- _Однострочные комментарии_ +- _Многострочное комментирование_ + +```js +// комментирование самого кода одним комментарием +// let firstName = 'Asabeneh'; однострочный комментарий +// let lastName = 'Yetayeh'; однострочный комментарий +``` + +Многострочное комментирование: + +```js +/* + let location = 'Helsinki'; + let age = 100; + let isMarried = true; + This is a Multiple line comment +*/ +``` + +## Переменные + +Переменные являются _контейнером_ данных. Переменные, используются для хранения данных в ячейке памяти. Когда переменная объявлена, место в памяти зарезервировано. Когда переменной присваивается значение (данные), пространство памяти будет заполнено этими данными. Чтобы объявить переменную, мы используем ключевые слова `var`, `let` или `const`. Мы поговорим подробнее о `var`, `let` и `const` в других разделах (область действия). Пока приведенного выше объяснения достаточно. + +Для переменной, которая изменяется в другое время, мы используем `let`. Если данные не меняются вообще, мы используем `const`. Например, PI, название страны, гравитация не меняются, и мы можем использовать `const`. + +- Имя переменной JavaScript не должно начинаться с цифры. +- Имя переменной JavaScript не допускает специальных символов, кроме знака доллара и подчеркивания. +- Имя переменной JavaScript следует соглашению camelCase. +- Имя переменной JavaScript не должно содержать пробелов между словами. + +Ниже приведены допустимые примеры переменных JavaScript. + +Допустимые переменные в JavaScript: + +```js +firstName; +lastName; +country; +city; +capitalCity; +age; +isMarried; + +first_name; +last_name; +is_marreid; +capital_city; + +num1; +num_1; +_num_1; +$num1; +year2020; +year_2020; +``` + +camelCase или первый способ декларирования обычно используются в JavaScript. В этом материале мы будем использовать переменные camelCase. + +Неверное название переменных: + +```sh +first-name +1_num +num_#_1 +``` + +Давайте объявим переменные с разными типами данных. Чтобы объявить переменную, нам нужно использовать ключевое слово let или const перед именем переменной. После имени переменной мы пишем знак равенства (оператор присваивания) и значение. + +```js +// Синтаксис +let nameOfVariable = value; +``` + +### Примеры: Переменные + +```js +// Объявление разных переменных разных типов данных +let firstName = "Asabeneh"; // имя человека +let lastName = "Yetayeh"; // фамилия человека +let country = "Finland"; // страна +let city = "Helsinki"; // столица +let age = 100; // возраст в годах +let isMarried = true; + +console.log(firstName, lastName, country, city, age, isMarried); +``` + +```sh +Asabeneh Yetayeh Finland Helsinki 100 True +``` + +```js +// Объявление переменных с числовыми значениями +let age = 100; // возраст в годах +const gravity = 9.81; // сила тяжести на землю в м/с2 +const boilingPoint = 100; // температура кипения воды, температура в oC +const PI = 3.14; // геометрическая постоянная + +console.log(gravity, boilingPoint, PI); +``` + +```sh +9.81 100 3.14 +``` + +```js +// Переменные также могут быть объявлены в одну строку через запятую +let name = "Asabeneh", // Имя человека + job = "teacher", + live = "Finland"; +console.log(name, job, live); +``` + +```sh +Asabeneh teacher Finland +``` + +Когда вы запускаете файлы в папке 01-Day, вы должны получить это: + +![Day one](./images/day_1.png) + +🌕 Ты великолепен. Вы только что выполнили задание первого дня, и вы на пути к величию. Теперь сделайте несколько упражнений для вашего мозга и ваших мышц. + +# 💻 День 1: Упражнения + +1. Написать однострочный комментарий, который говорит: _comments can make code readable_ +2. Написать еще один комментарий, который говорит: _welcome to 30DaysOfJavaScript_ +3. Написать многострочный комментарий, который говорит: _comments can make code readable, easy to use and informative_ +4. Создать файл _variable.js_, объявить переменные и назначить строковые, логические, undefined и null типы данных. +5. Создайте файл _datatypes.js_ и используйте оператор JavaScript `typeof` для проверки различных типов данных. Проверьте тип данных каждой переменной +6. Объявите четыре переменные без присвоения значений +7. Объявите четыре переменные с присвоением значений +8. Объявите переменные для хранения вашего имени, фамилии, семейного положения, страны и возраста в несколько строк +9. Объявите переменные, чтобы хранить ваши имя, фамилию, семейное положение, страну и возраст в одной строке +10. Объявите две переменные _myAge_ и _yourAge_, присвойте им начальные значения и войдите в консоль браузера. + +```sh +I am 25 years old. +You are 30 years old. +``` + +🎉 ПОЗДРАВЛЯЕМ ! 🎉 + +[День 2 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/RU/02_Day/02_day_data_types.md) diff --git a/RU/data/countries.js b/RU/data/countries.js new file mode 100644 index 0000000..e57b005 --- /dev/null +++ b/RU/data/countries.js @@ -0,0 +1,195 @@ +const countries = [ + 'Afghanistan', + 'Albania', + 'Algeria', + 'Andorra', + 'Angola', + 'Antigua and Barbuda', + 'Argentina', + 'Armenia', + 'Australia', + 'Austria', + 'Azerbaijan', + 'Bahamas', + 'Bahrain', + 'Bangladesh', + 'Barbados', + 'Belarus', + 'Belgium', + 'Belize', + 'Benin', + 'Bhutan', + 'Bolivia', + 'Bosnia and Herzegovina', + 'Botswana', + 'Brazil', + 'Brunei', + 'Bulgaria', + 'Burkina Faso', + 'Burundi', + 'Cambodia', + 'Cameroon', + 'Canada', + 'Cape Verde', + 'Central African Republic', + 'Chad', + 'Chile', + 'China', + 'Colombi', + 'Comoros', + 'Congo (Brazzaville)', + 'Congo', + 'Costa Rica', + "Cote d'Ivoire", + 'Croatia', + 'Cuba', + 'Cyprus', + 'Czech Republic', + 'Denmark', + 'Djibouti', + 'Dominica', + 'Dominican Republic', + 'East Timor (Timor Timur)', + 'Ecuador', + 'Egypt', + 'El Salvador', + 'Equatorial Guinea', + 'Eritrea', + 'Estonia', + 'Ethiopia', + 'Fiji', + 'Finland', + 'France', + 'Gabon', + 'Gambia, The', + 'Georgia', + 'Germany', + 'Ghana', + 'Greece', + 'Grenada', + 'Guatemala', + 'Guinea', + 'Guinea-Bissau', + 'Guyana', + 'Haiti', + 'Honduras', + 'Hungary', + 'Iceland', + 'India', + 'Indonesia', + 'Iran', + 'Iraq', + 'Ireland', + 'Israel', + 'Italy', + 'Jamaica', + 'Japan', + 'Jordan', + 'Kazakhstan', + 'Kenya', + 'Kiribati', + 'Korea, North', + 'Korea, South', + 'Kuwait', + 'Kyrgyzstan', + 'Laos', + 'Latvia', + 'Lebanon', + 'Lesotho', + 'Liberia', + 'Libya', + 'Liechtenstein', + 'Lithuania', + 'Luxembourg', + 'Macedonia', + 'Madagascar', + 'Malawi', + 'Malaysia', + 'Maldives', + 'Mali', + 'Malta', + 'Marshall Islands', + 'Mauritania', + 'Mauritius', + 'Mexico', + 'Micronesia', + 'Moldova', + 'Monaco', + 'Mongolia', + 'Morocco', + 'Mozambique', + 'Myanmar', + 'Namibia', + 'Nauru', + 'Nepal', + 'Netherlands', + 'New Zealand', + 'Nicaragua', + 'Niger', + 'Nigeria', + 'Norway', + 'Oman', + 'Pakistan', + 'Palau', + 'Panama', + 'Papua New Guinea', + 'Paraguay', + 'Peru', + 'Philippines', + 'Poland', + 'Portugal', + 'Qatar', + 'Romania', + 'Russia', + 'Rwanda', + 'Saint Kitts and Nevis', + 'Saint Lucia', + 'Saint Vincent', + 'Samoa', + 'San Marino', + 'Sao Tome and Principe', + 'Saudi Arabia', + 'Senegal', + 'Serbia and Montenegro', + 'Seychelles', + 'Sierra Leone', + 'Singapore', + 'Slovakia', + 'Slovenia', + 'Solomon Islands', + 'Somalia', + 'South Africa', + 'Spain', + 'Sri Lanka', + 'Sudan', + 'Suriname', + 'Swaziland', + 'Sweden', + 'Switzerland', + 'Syria', + 'Taiwan', + 'Tajikistan', + 'Tanzania', + 'Thailand', + 'Togo', + 'Tonga', + 'Trinidad and Tobago', + 'Tunisia', + 'Turkey', + 'Turkmenistan', + 'Tuvalu', + 'Uganda', + 'Ukraine', + 'United Arab Emirates', + 'United Kingdom', + 'United States', + 'Uruguay', + 'Uzbekistan', + 'Vanuatu', + 'Vatican City', + 'Venezuela', + 'Vietnam', + 'Yemen', + 'Zambia', + 'Zimbabwe' +] diff --git a/RU/images/30DaysOfJavaScript.png b/RU/images/30DaysOfJavaScript.png new file mode 100644 index 0000000..4142286 Binary files /dev/null and b/RU/images/30DaysOfJavaScript.png differ diff --git a/RU/images/adding_project_to_vscode.png b/RU/images/adding_project_to_vscode.png new file mode 100644 index 0000000..1935860 Binary files /dev/null and b/RU/images/adding_project_to_vscode.png differ diff --git a/RU/images/arithmetic.png b/RU/images/arithmetic.png new file mode 100644 index 0000000..9830916 Binary files /dev/null and b/RU/images/arithmetic.png differ diff --git a/RU/images/array_index.png b/RU/images/array_index.png new file mode 100644 index 0000000..355324e Binary files /dev/null and b/RU/images/array_index.png differ diff --git a/RU/images/assignment_operators.png b/RU/images/assignment_operators.png new file mode 100644 index 0000000..99d51d2 Binary files /dev/null and b/RU/images/assignment_operators.png differ diff --git a/RU/images/banners/Day -1 – 31.png b/RU/images/banners/Day -1 – 31.png new file mode 100644 index 0000000..d9a9639 Binary files /dev/null and b/RU/images/banners/Day -1 – 31.png differ diff --git a/RU/images/banners/day_1_1.png b/RU/images/banners/day_1_1.png new file mode 100644 index 0000000..dd583c7 Binary files /dev/null and b/RU/images/banners/day_1_1.png differ diff --git a/RU/images/banners/day_1_10.png b/RU/images/banners/day_1_10.png new file mode 100644 index 0000000..e063dec Binary files /dev/null and b/RU/images/banners/day_1_10.png differ diff --git a/RU/images/banners/day_1_11.png b/RU/images/banners/day_1_11.png new file mode 100644 index 0000000..0c2d60b Binary files /dev/null and b/RU/images/banners/day_1_11.png differ diff --git a/RU/images/banners/day_1_12.png b/RU/images/banners/day_1_12.png new file mode 100644 index 0000000..232ac85 Binary files /dev/null and b/RU/images/banners/day_1_12.png differ diff --git a/RU/images/banners/day_1_13.png b/RU/images/banners/day_1_13.png new file mode 100644 index 0000000..488f522 Binary files /dev/null and b/RU/images/banners/day_1_13.png differ diff --git a/RU/images/banners/day_1_14.png b/RU/images/banners/day_1_14.png new file mode 100644 index 0000000..4c5a568 Binary files /dev/null and b/RU/images/banners/day_1_14.png differ diff --git a/RU/images/banners/day_1_15.png b/RU/images/banners/day_1_15.png new file mode 100644 index 0000000..e3013f6 Binary files /dev/null and b/RU/images/banners/day_1_15.png differ diff --git a/images/banners/Day -1 – 16.png b/RU/images/banners/day_1_16.png similarity index 100% rename from images/banners/Day -1 – 16.png rename to RU/images/banners/day_1_16.png diff --git a/images/banners/Day -1 – 17.png b/RU/images/banners/day_1_17.png similarity index 100% rename from images/banners/Day -1 – 17.png rename to RU/images/banners/day_1_17.png diff --git a/images/banners/Day -1 – 18.png b/RU/images/banners/day_1_18.png similarity index 100% rename from images/banners/Day -1 – 18.png rename to RU/images/banners/day_1_18.png diff --git a/images/banners/Day -1 – 19.png b/RU/images/banners/day_1_19.png similarity index 100% rename from images/banners/Day -1 – 19.png rename to RU/images/banners/day_1_19.png diff --git a/RU/images/banners/day_1_2.png b/RU/images/banners/day_1_2.png new file mode 100644 index 0000000..0f6eefb Binary files /dev/null and b/RU/images/banners/day_1_2.png differ diff --git a/images/banners/Day -1 – 20.png b/RU/images/banners/day_1_20.png similarity index 100% rename from images/banners/Day -1 – 20.png rename to RU/images/banners/day_1_20.png diff --git a/images/banners/Day -1 – 21.png b/RU/images/banners/day_1_21.png similarity index 100% rename from images/banners/Day -1 – 21.png rename to RU/images/banners/day_1_21.png diff --git a/images/banners/Day -1 – 22.png b/RU/images/banners/day_1_22.png similarity index 100% rename from images/banners/Day -1 – 22.png rename to RU/images/banners/day_1_22.png diff --git a/images/banners/Day -1 – 23.png b/RU/images/banners/day_1_23.png similarity index 100% rename from images/banners/Day -1 – 23.png rename to RU/images/banners/day_1_23.png diff --git a/images/banners/Day -1 – 24.png b/RU/images/banners/day_1_24.png similarity index 100% rename from images/banners/Day -1 – 24.png rename to RU/images/banners/day_1_24.png diff --git a/images/banners/Day -1 – 25.png b/RU/images/banners/day_1_25.png similarity index 100% rename from images/banners/Day -1 – 25.png rename to RU/images/banners/day_1_25.png diff --git a/images/banners/Day -1 – 26.png b/RU/images/banners/day_1_26.png similarity index 100% rename from images/banners/Day -1 – 26.png rename to RU/images/banners/day_1_26.png diff --git a/images/banners/Day -1 – 27.png b/RU/images/banners/day_1_27.png similarity index 100% rename from images/banners/Day -1 – 27.png rename to RU/images/banners/day_1_27.png diff --git a/images/banners/Day -1 – 28.png b/RU/images/banners/day_1_28.png similarity index 100% rename from images/banners/Day -1 – 28.png rename to RU/images/banners/day_1_28.png diff --git a/images/banners/Day -1 – 29.png b/RU/images/banners/day_1_29.png similarity index 100% rename from images/banners/Day -1 – 29.png rename to RU/images/banners/day_1_29.png diff --git a/RU/images/banners/day_1_3.png b/RU/images/banners/day_1_3.png new file mode 100644 index 0000000..1268d2c Binary files /dev/null and b/RU/images/banners/day_1_3.png differ diff --git a/images/banners/Day -1 – 30.png b/RU/images/banners/day_1_30.png similarity index 100% rename from images/banners/Day -1 – 30.png rename to RU/images/banners/day_1_30.png diff --git a/RU/images/banners/day_1_4.png b/RU/images/banners/day_1_4.png new file mode 100644 index 0000000..d5262c6 Binary files /dev/null and b/RU/images/banners/day_1_4.png differ diff --git a/RU/images/banners/day_1_5.png b/RU/images/banners/day_1_5.png new file mode 100644 index 0000000..21bc08c Binary files /dev/null and b/RU/images/banners/day_1_5.png differ diff --git a/RU/images/banners/day_1_6.png b/RU/images/banners/day_1_6.png new file mode 100644 index 0000000..dbea5fd Binary files /dev/null and b/RU/images/banners/day_1_6.png differ diff --git a/RU/images/banners/day_1_7.png b/RU/images/banners/day_1_7.png new file mode 100644 index 0000000..eff8dac Binary files /dev/null and b/RU/images/banners/day_1_7.png differ diff --git a/RU/images/banners/day_1_8.png b/RU/images/banners/day_1_8.png new file mode 100644 index 0000000..ddf9007 Binary files /dev/null and b/RU/images/banners/day_1_8.png differ diff --git a/RU/images/banners/day_1_9.png b/RU/images/banners/day_1_9.png new file mode 100644 index 0000000..1cf688b Binary files /dev/null and b/RU/images/banners/day_1_9.png differ diff --git a/RU/images/comparison_operators.png b/RU/images/comparison_operators.png new file mode 100644 index 0000000..26ccb91 Binary files /dev/null and b/RU/images/comparison_operators.png differ diff --git a/RU/images/console_log_multipl_arguments.png b/RU/images/console_log_multipl_arguments.png new file mode 100644 index 0000000..f324a90 Binary files /dev/null and b/RU/images/console_log_multipl_arguments.png differ diff --git a/RU/images/date_time_object.png b/RU/images/date_time_object.png new file mode 100644 index 0000000..c5297c7 Binary files /dev/null and b/RU/images/date_time_object.png differ diff --git a/RU/images/day_1.png b/RU/images/day_1.png new file mode 100644 index 0000000..7daf57f Binary files /dev/null and b/RU/images/day_1.png differ diff --git a/RU/images/day_1_1.png b/RU/images/day_1_1.png new file mode 100644 index 0000000..dd583c7 Binary files /dev/null and b/RU/images/day_1_1.png differ diff --git a/RU/images/download_node.png b/RU/images/download_node.png new file mode 100644 index 0000000..f290b20 Binary files /dev/null and b/RU/images/download_node.png differ diff --git a/RU/images/google_chrome.png b/RU/images/google_chrome.png new file mode 100644 index 0000000..af06acd Binary files /dev/null and b/RU/images/google_chrome.png differ diff --git a/RU/images/install_node.png b/RU/images/install_node.png new file mode 100644 index 0000000..e5aecf1 Binary files /dev/null and b/RU/images/install_node.png differ diff --git a/RU/images/js_code_on_chrome_console.png b/RU/images/js_code_on_chrome_console.png new file mode 100644 index 0000000..7d6002c Binary files /dev/null and b/RU/images/js_code_on_chrome_console.png differ diff --git a/RU/images/js_code_vscode.png b/RU/images/js_code_vscode.png new file mode 100644 index 0000000..6e1a661 Binary files /dev/null and b/RU/images/js_code_vscode.png differ diff --git a/RU/images/launched_on_new_tab.png b/RU/images/launched_on_new_tab.png new file mode 100644 index 0000000..ed377dc Binary files /dev/null and b/RU/images/launched_on_new_tab.png differ diff --git a/RU/images/local_storage.png b/RU/images/local_storage.png new file mode 100644 index 0000000..0876852 Binary files /dev/null and b/RU/images/local_storage.png differ diff --git a/RU/images/multiple_script.png b/RU/images/multiple_script.png new file mode 100644 index 0000000..caa067f Binary files /dev/null and b/RU/images/multiple_script.png differ diff --git a/RU/images/opening_chrome_console_shortcut.png b/RU/images/opening_chrome_console_shortcut.png new file mode 100644 index 0000000..eace03f Binary files /dev/null and b/RU/images/opening_chrome_console_shortcut.png differ diff --git a/RU/images/opening_developer_tool.png b/RU/images/opening_developer_tool.png new file mode 100644 index 0000000..6eb33dd Binary files /dev/null and b/RU/images/opening_developer_tool.png differ diff --git a/RU/images/opening_project_on_vscode.png b/RU/images/opening_project_on_vscode.png new file mode 100644 index 0000000..908c8fd Binary files /dev/null and b/RU/images/opening_project_on_vscode.png differ diff --git a/RU/images/projects/congratulations.gif b/RU/images/projects/congratulations.gif new file mode 100644 index 0000000..cddd6c4 Binary files /dev/null and b/RU/images/projects/congratulations.gif differ diff --git a/RU/images/projects/dom_min_project_30DaysOfJavaScript_color_changing_day_9.1.gif b/RU/images/projects/dom_min_project_30DaysOfJavaScript_color_changing_day_9.1.gif new file mode 100644 index 0000000..c8d2f2b Binary files /dev/null and b/RU/images/projects/dom_min_project_30DaysOfJavaScript_color_changing_day_9.1.gif differ diff --git a/RU/images/projects/dom_min_project_bar_graph_day_5.1.gif b/RU/images/projects/dom_min_project_bar_graph_day_5.1.gif new file mode 100644 index 0000000..a7d7962 Binary files /dev/null and b/RU/images/projects/dom_min_project_bar_graph_day_5.1.gif differ diff --git a/RU/images/projects/dom_min_project_bar_graph_day_5.1.png b/RU/images/projects/dom_min_project_bar_graph_day_5.1.png new file mode 100644 index 0000000..0b6ccf7 Binary files /dev/null and b/RU/images/projects/dom_min_project_bar_graph_day_5.1.png differ diff --git a/RU/images/projects/dom_min_project_challenge_info_day_1.1.gif b/RU/images/projects/dom_min_project_challenge_info_day_1.1.gif new file mode 100644 index 0000000..0551771 Binary files /dev/null and b/RU/images/projects/dom_min_project_challenge_info_day_1.1.gif differ diff --git a/RU/images/projects/dom_min_project_challenge_info_day_1.1.png b/RU/images/projects/dom_min_project_challenge_info_day_1.1.png new file mode 100644 index 0000000..01a8d4f Binary files /dev/null and b/RU/images/projects/dom_min_project_challenge_info_day_1.1.png differ diff --git a/RU/images/projects/dom_min_project_countries_aray_day_2.2.png b/RU/images/projects/dom_min_project_countries_aray_day_2.2.png new file mode 100644 index 0000000..ca0e344 Binary files /dev/null and b/RU/images/projects/dom_min_project_countries_aray_day_2.2.png differ diff --git a/RU/images/projects/dom_min_project_day_7.1.gif b/RU/images/projects/dom_min_project_day_7.1.gif new file mode 100644 index 0000000..51bdadb Binary files /dev/null and b/RU/images/projects/dom_min_project_day_7.1.gif differ diff --git a/RU/images/projects/dom_min_project_day_number_generators_2.1.png b/RU/images/projects/dom_min_project_day_number_generators_2.1.png new file mode 100644 index 0000000..d69a6c2 Binary files /dev/null and b/RU/images/projects/dom_min_project_day_number_generators_2.1.png differ diff --git a/RU/images/projects/dom_min_project_keycode_day_3.2.gif b/RU/images/projects/dom_min_project_keycode_day_3.2.gif new file mode 100644 index 0000000..7c75c14 Binary files /dev/null and b/RU/images/projects/dom_min_project_keycode_day_3.2.gif differ diff --git a/RU/images/projects/dom_min_project_number_generator_day_3.1.gif b/RU/images/projects/dom_min_project_number_generator_day_3.1.gif new file mode 100644 index 0000000..59a8dd0 Binary files /dev/null and b/RU/images/projects/dom_min_project_number_generator_day_3.1.gif differ diff --git a/RU/images/projects/dom_min_project_solar_system_day_4.1.gif b/RU/images/projects/dom_min_project_solar_system_day_4.1.gif new file mode 100644 index 0000000..d88b04b Binary files /dev/null and b/RU/images/projects/dom_min_project_solar_system_day_4.1.gif differ diff --git a/RU/images/projects/dom_min_project_solar_system_day_4.1.mkv b/RU/images/projects/dom_min_project_solar_system_day_4.1.mkv new file mode 100644 index 0000000..1ed941c Binary files /dev/null and b/RU/images/projects/dom_min_project_solar_system_day_4.1.mkv differ diff --git a/RU/images/projects/dom_min_project_solar_system_day_4.1.mp4 b/RU/images/projects/dom_min_project_solar_system_day_4.1.mp4 new file mode 100644 index 0000000..69ce936 Binary files /dev/null and b/RU/images/projects/dom_min_project_solar_system_day_4.1.mp4 differ diff --git a/RU/images/projects/dom_mini_project_challenge_info_day_2.3.gif b/RU/images/projects/dom_mini_project_challenge_info_day_2.3.gif new file mode 100644 index 0000000..571ea6f Binary files /dev/null and b/RU/images/projects/dom_mini_project_challenge_info_day_2.3.gif differ diff --git a/RU/images/projects/dom_mini_project_challenge_info_day_2.3.png b/RU/images/projects/dom_mini_project_challenge_info_day_2.3.png new file mode 100644 index 0000000..3387bea Binary files /dev/null and b/RU/images/projects/dom_mini_project_challenge_info_day_2.3.png differ diff --git a/RU/images/projects/dom_mini_project_countries_day_6.1.gif b/RU/images/projects/dom_mini_project_countries_day_6.1.gif new file mode 100644 index 0000000..8a8f09a Binary files /dev/null and b/RU/images/projects/dom_mini_project_countries_day_6.1.gif differ diff --git a/RU/images/projects/dom_mini_project_countries_object_day_10.1.gif b/RU/images/projects/dom_mini_project_countries_object_day_10.1.gif new file mode 100644 index 0000000..03b1e35 Binary files /dev/null and b/RU/images/projects/dom_mini_project_countries_object_day_10.1.gif differ diff --git a/RU/images/projects/dom_mini_project_form_validation_day_10.2.1.png b/RU/images/projects/dom_mini_project_form_validation_day_10.2.1.png new file mode 100644 index 0000000..9d2c2b3 Binary files /dev/null and b/RU/images/projects/dom_mini_project_form_validation_day_10.2.1.png differ diff --git a/RU/images/projects/dom_mini_project_form_validation_day_10.2.png b/RU/images/projects/dom_mini_project_form_validation_day_10.2.png new file mode 100644 index 0000000..ca7cdd5 Binary files /dev/null and b/RU/images/projects/dom_mini_project_form_validation_day_10.2.png differ diff --git a/RU/images/projects/dom_mini_project_leaderboard_day_8.1.gif b/RU/images/projects/dom_mini_project_leaderboard_day_8.1.gif new file mode 100644 index 0000000..789d0cb Binary files /dev/null and b/RU/images/projects/dom_mini_project_leaderboard_day_8.1.gif differ diff --git a/RU/images/projects/dom_mini_project_leaderboard_day_8.1.png b/RU/images/projects/dom_mini_project_leaderboard_day_8.1.png new file mode 100644 index 0000000..2956fa0 Binary files /dev/null and b/RU/images/projects/dom_mini_project_leaderboard_day_8.1.png differ diff --git a/RU/images/projects/dom_mini_project_slider_day_7.1.gif b/RU/images/projects/dom_mini_project_slider_day_7.1.gif new file mode 100644 index 0000000..51bdadb Binary files /dev/null and b/RU/images/projects/dom_mini_project_slider_day_7.1.gif differ diff --git a/RU/images/raising_syntax_error.png b/RU/images/raising_syntax_error.png new file mode 100644 index 0000000..81f6245 Binary files /dev/null and b/RU/images/raising_syntax_error.png differ diff --git a/RU/images/regex.png b/RU/images/regex.png new file mode 100644 index 0000000..c7116b4 Binary files /dev/null and b/RU/images/regex.png differ diff --git a/RU/images/running_script.png b/RU/images/running_script.png new file mode 100644 index 0000000..deac13d Binary files /dev/null and b/RU/images/running_script.png differ diff --git a/RU/images/scripts_on_vscode.png b/RU/images/scripts_on_vscode.png new file mode 100644 index 0000000..f6257be Binary files /dev/null and b/RU/images/scripts_on_vscode.png differ diff --git a/RU/images/string_indexes.png b/RU/images/string_indexes.png new file mode 100644 index 0000000..cc2f638 Binary files /dev/null and b/RU/images/string_indexes.png differ diff --git a/RU/images/vscode.png b/RU/images/vscode.png new file mode 100644 index 0000000..724fc10 Binary files /dev/null and b/RU/images/vscode.png differ diff --git a/RU/images/vscode_ui.png b/RU/images/vscode_ui.png new file mode 100644 index 0000000..7210a08 Binary files /dev/null and b/RU/images/vscode_ui.png differ diff --git a/RU/images/web_storage.png b/RU/images/web_storage.png new file mode 100644 index 0000000..46f9311 Binary files /dev/null and b/RU/images/web_storage.png differ diff --git a/RU/index.html b/RU/index.html new file mode 100644 index 0000000..14e41c3 --- /dev/null +++ b/RU/index.html @@ -0,0 +1,128 @@ + + + + + Document Object Model:30 Days Of JavaScript + + + + + + +
    +

    Asabeneh Yetayeh challenges in 2020

    +

    30DaysOfJavaScript Challenge

    +

    +
      +
    • 30DaysOfPython Challenge Done
    • +
    • 30DaysOfJavaScript Challenge Ongoing
    • +
    • 30DaysOfReact Challenge Coming
    • +
    • 30DaysOfReactNative Challenge Coming
    • +
    • 30DaysOfFullStack Challenge Coming
    • +
    • 30DaysOfDataAnalysis Challenge Coming
    • +
    • 30DaysOfMachineLearning Challenge Coming
    • +
    +
    + + + + + \ No newline at end of file diff --git a/Spanish/images/30DaysOfJavaScript.png b/Spanish/images/30DaysOfJavaScript.png new file mode 100644 index 0000000..4142286 Binary files /dev/null and b/Spanish/images/30DaysOfJavaScript.png differ diff --git a/Spanish/images/adding_project_to_vscode.png b/Spanish/images/adding_project_to_vscode.png new file mode 100644 index 0000000..1935860 Binary files /dev/null and b/Spanish/images/adding_project_to_vscode.png differ diff --git a/Spanish/images/arithmetic.png b/Spanish/images/arithmetic.png new file mode 100644 index 0000000..9830916 Binary files /dev/null and b/Spanish/images/arithmetic.png differ diff --git a/Spanish/images/array_index.png b/Spanish/images/array_index.png new file mode 100644 index 0000000..355324e Binary files /dev/null and b/Spanish/images/array_index.png differ diff --git a/Spanish/images/assignment_operators.png b/Spanish/images/assignment_operators.png new file mode 100644 index 0000000..99d51d2 Binary files /dev/null and b/Spanish/images/assignment_operators.png differ diff --git a/Spanish/images/banners/Day -1 – 31.png b/Spanish/images/banners/Day -1 – 31.png new file mode 100644 index 0000000..d9a9639 Binary files /dev/null and b/Spanish/images/banners/Day -1 – 31.png differ diff --git a/Spanish/images/banners/day_1_1.png b/Spanish/images/banners/day_1_1.png new file mode 100644 index 0000000..dd583c7 Binary files /dev/null and b/Spanish/images/banners/day_1_1.png differ diff --git a/Spanish/images/banners/day_1_10.png b/Spanish/images/banners/day_1_10.png new file mode 100644 index 0000000..e063dec Binary files /dev/null and b/Spanish/images/banners/day_1_10.png differ diff --git a/Spanish/images/banners/day_1_11.png b/Spanish/images/banners/day_1_11.png new file mode 100644 index 0000000..0c2d60b Binary files /dev/null and b/Spanish/images/banners/day_1_11.png differ diff --git a/Spanish/images/banners/day_1_12.png b/Spanish/images/banners/day_1_12.png new file mode 100644 index 0000000..232ac85 Binary files /dev/null and b/Spanish/images/banners/day_1_12.png differ diff --git a/Spanish/images/banners/day_1_13.png b/Spanish/images/banners/day_1_13.png new file mode 100644 index 0000000..488f522 Binary files /dev/null and b/Spanish/images/banners/day_1_13.png differ diff --git a/Spanish/images/banners/day_1_14.png b/Spanish/images/banners/day_1_14.png new file mode 100644 index 0000000..4c5a568 Binary files /dev/null and b/Spanish/images/banners/day_1_14.png differ diff --git a/Spanish/images/banners/day_1_15.png b/Spanish/images/banners/day_1_15.png new file mode 100644 index 0000000..e3013f6 Binary files /dev/null and b/Spanish/images/banners/day_1_15.png differ diff --git a/Spanish/images/banners/day_1_16.png b/Spanish/images/banners/day_1_16.png new file mode 100644 index 0000000..d116060 Binary files /dev/null and b/Spanish/images/banners/day_1_16.png differ diff --git a/Spanish/images/banners/day_1_17.png b/Spanish/images/banners/day_1_17.png new file mode 100644 index 0000000..69cf7ae Binary files /dev/null and b/Spanish/images/banners/day_1_17.png differ diff --git a/Spanish/images/banners/day_1_18.png b/Spanish/images/banners/day_1_18.png new file mode 100644 index 0000000..8b69340 Binary files /dev/null and b/Spanish/images/banners/day_1_18.png differ diff --git a/Spanish/images/banners/day_1_19.png b/Spanish/images/banners/day_1_19.png new file mode 100644 index 0000000..2a785c9 Binary files /dev/null and b/Spanish/images/banners/day_1_19.png differ diff --git a/Spanish/images/banners/day_1_2.png b/Spanish/images/banners/day_1_2.png new file mode 100644 index 0000000..0f6eefb Binary files /dev/null and b/Spanish/images/banners/day_1_2.png differ diff --git a/Spanish/images/banners/day_1_20.png b/Spanish/images/banners/day_1_20.png new file mode 100644 index 0000000..befe1fc Binary files /dev/null and b/Spanish/images/banners/day_1_20.png differ diff --git a/Spanish/images/banners/day_1_21.png b/Spanish/images/banners/day_1_21.png new file mode 100644 index 0000000..634d1eb Binary files /dev/null and b/Spanish/images/banners/day_1_21.png differ diff --git a/Spanish/images/banners/day_1_22.png b/Spanish/images/banners/day_1_22.png new file mode 100644 index 0000000..81e33d9 Binary files /dev/null and b/Spanish/images/banners/day_1_22.png differ diff --git a/Spanish/images/banners/day_1_23.png b/Spanish/images/banners/day_1_23.png new file mode 100644 index 0000000..ceb0321 Binary files /dev/null and b/Spanish/images/banners/day_1_23.png differ diff --git a/Spanish/images/banners/day_1_24.png b/Spanish/images/banners/day_1_24.png new file mode 100644 index 0000000..9c8ec46 Binary files /dev/null and b/Spanish/images/banners/day_1_24.png differ diff --git a/Spanish/images/banners/day_1_25.png b/Spanish/images/banners/day_1_25.png new file mode 100644 index 0000000..60a211e Binary files /dev/null and b/Spanish/images/banners/day_1_25.png differ diff --git a/Spanish/images/banners/day_1_26.png b/Spanish/images/banners/day_1_26.png new file mode 100644 index 0000000..f187f2c Binary files /dev/null and b/Spanish/images/banners/day_1_26.png differ diff --git a/Spanish/images/banners/day_1_27.png b/Spanish/images/banners/day_1_27.png new file mode 100644 index 0000000..8637069 Binary files /dev/null and b/Spanish/images/banners/day_1_27.png differ diff --git a/Spanish/images/banners/day_1_28.png b/Spanish/images/banners/day_1_28.png new file mode 100644 index 0000000..1858aca Binary files /dev/null and b/Spanish/images/banners/day_1_28.png differ diff --git a/Spanish/images/banners/day_1_29.png b/Spanish/images/banners/day_1_29.png new file mode 100644 index 0000000..959ee36 Binary files /dev/null and b/Spanish/images/banners/day_1_29.png differ diff --git a/Spanish/images/banners/day_1_3.png b/Spanish/images/banners/day_1_3.png new file mode 100644 index 0000000..1268d2c Binary files /dev/null and b/Spanish/images/banners/day_1_3.png differ diff --git a/Spanish/images/banners/day_1_30.png b/Spanish/images/banners/day_1_30.png new file mode 100644 index 0000000..18a77c4 Binary files /dev/null and b/Spanish/images/banners/day_1_30.png differ diff --git a/Spanish/images/banners/day_1_4.png b/Spanish/images/banners/day_1_4.png new file mode 100644 index 0000000..d5262c6 Binary files /dev/null and b/Spanish/images/banners/day_1_4.png differ diff --git a/Spanish/images/banners/day_1_5.png b/Spanish/images/banners/day_1_5.png new file mode 100644 index 0000000..21bc08c Binary files /dev/null and b/Spanish/images/banners/day_1_5.png differ diff --git a/Spanish/images/banners/day_1_6.png b/Spanish/images/banners/day_1_6.png new file mode 100644 index 0000000..dbea5fd Binary files /dev/null and b/Spanish/images/banners/day_1_6.png differ diff --git a/Spanish/images/banners/day_1_7.png b/Spanish/images/banners/day_1_7.png new file mode 100644 index 0000000..eff8dac Binary files /dev/null and b/Spanish/images/banners/day_1_7.png differ diff --git a/Spanish/images/banners/day_1_8.png b/Spanish/images/banners/day_1_8.png new file mode 100644 index 0000000..ddf9007 Binary files /dev/null and b/Spanish/images/banners/day_1_8.png differ diff --git a/Spanish/images/banners/day_1_9.png b/Spanish/images/banners/day_1_9.png new file mode 100644 index 0000000..1cf688b Binary files /dev/null and b/Spanish/images/banners/day_1_9.png differ diff --git a/Spanish/images/comparison_operators.png b/Spanish/images/comparison_operators.png new file mode 100644 index 0000000..26ccb91 Binary files /dev/null and b/Spanish/images/comparison_operators.png differ diff --git a/Spanish/images/console_log_multipl_arguments.png b/Spanish/images/console_log_multipl_arguments.png new file mode 100644 index 0000000..f324a90 Binary files /dev/null and b/Spanish/images/console_log_multipl_arguments.png differ diff --git a/Spanish/images/date_time_object.png b/Spanish/images/date_time_object.png new file mode 100644 index 0000000..c5297c7 Binary files /dev/null and b/Spanish/images/date_time_object.png differ diff --git a/Spanish/images/day_1.png b/Spanish/images/day_1.png new file mode 100644 index 0000000..7daf57f Binary files /dev/null and b/Spanish/images/day_1.png differ diff --git a/Spanish/images/day_1_1.png b/Spanish/images/day_1_1.png new file mode 100644 index 0000000..dd583c7 Binary files /dev/null and b/Spanish/images/day_1_1.png differ diff --git a/Spanish/images/download_node.png b/Spanish/images/download_node.png new file mode 100644 index 0000000..f290b20 Binary files /dev/null and b/Spanish/images/download_node.png differ diff --git a/Spanish/images/google_chrome.png b/Spanish/images/google_chrome.png new file mode 100644 index 0000000..af06acd Binary files /dev/null and b/Spanish/images/google_chrome.png differ diff --git a/Spanish/images/install_node.png b/Spanish/images/install_node.png new file mode 100644 index 0000000..e5aecf1 Binary files /dev/null and b/Spanish/images/install_node.png differ diff --git a/Spanish/images/js_code_on_chrome_console.png b/Spanish/images/js_code_on_chrome_console.png new file mode 100644 index 0000000..7d6002c Binary files /dev/null and b/Spanish/images/js_code_on_chrome_console.png differ diff --git a/Spanish/images/js_code_vscode.png b/Spanish/images/js_code_vscode.png new file mode 100644 index 0000000..6e1a661 Binary files /dev/null and b/Spanish/images/js_code_vscode.png differ diff --git a/Spanish/images/launched_on_new_tab.png b/Spanish/images/launched_on_new_tab.png new file mode 100644 index 0000000..ed377dc Binary files /dev/null and b/Spanish/images/launched_on_new_tab.png differ diff --git a/Spanish/images/local_storage.png b/Spanish/images/local_storage.png new file mode 100644 index 0000000..0876852 Binary files /dev/null and b/Spanish/images/local_storage.png differ diff --git a/Spanish/images/multiple_script.png b/Spanish/images/multiple_script.png new file mode 100644 index 0000000..caa067f Binary files /dev/null and b/Spanish/images/multiple_script.png differ diff --git a/Spanish/images/opening_chrome_console_shortcut.png b/Spanish/images/opening_chrome_console_shortcut.png new file mode 100644 index 0000000..eace03f Binary files /dev/null and b/Spanish/images/opening_chrome_console_shortcut.png differ diff --git a/Spanish/images/opening_developer_tool.png b/Spanish/images/opening_developer_tool.png new file mode 100644 index 0000000..6eb33dd Binary files /dev/null and b/Spanish/images/opening_developer_tool.png differ diff --git a/Spanish/images/opening_project_on_vscode.png b/Spanish/images/opening_project_on_vscode.png new file mode 100644 index 0000000..908c8fd Binary files /dev/null and b/Spanish/images/opening_project_on_vscode.png differ diff --git a/Spanish/images/projects/congratulations.gif b/Spanish/images/projects/congratulations.gif new file mode 100644 index 0000000..cddd6c4 Binary files /dev/null and b/Spanish/images/projects/congratulations.gif differ diff --git a/Spanish/images/projects/dom_min_project_30DaysOfJavaScript_color_changing_day_9.1.gif b/Spanish/images/projects/dom_min_project_30DaysOfJavaScript_color_changing_day_9.1.gif new file mode 100644 index 0000000..c8d2f2b Binary files /dev/null and b/Spanish/images/projects/dom_min_project_30DaysOfJavaScript_color_changing_day_9.1.gif differ diff --git a/Spanish/images/projects/dom_min_project_bar_graph_day_5.1.gif b/Spanish/images/projects/dom_min_project_bar_graph_day_5.1.gif new file mode 100644 index 0000000..a7d7962 Binary files /dev/null and b/Spanish/images/projects/dom_min_project_bar_graph_day_5.1.gif differ diff --git a/Spanish/images/projects/dom_min_project_bar_graph_day_5.1.png b/Spanish/images/projects/dom_min_project_bar_graph_day_5.1.png new file mode 100644 index 0000000..0b6ccf7 Binary files /dev/null and b/Spanish/images/projects/dom_min_project_bar_graph_day_5.1.png differ diff --git a/Spanish/images/projects/dom_min_project_challenge_info_day_1.1.gif b/Spanish/images/projects/dom_min_project_challenge_info_day_1.1.gif new file mode 100644 index 0000000..0551771 Binary files /dev/null and b/Spanish/images/projects/dom_min_project_challenge_info_day_1.1.gif differ diff --git a/Spanish/images/projects/dom_min_project_challenge_info_day_1.1.png b/Spanish/images/projects/dom_min_project_challenge_info_day_1.1.png new file mode 100644 index 0000000..01a8d4f Binary files /dev/null and b/Spanish/images/projects/dom_min_project_challenge_info_day_1.1.png differ diff --git a/Spanish/images/projects/dom_min_project_countries_aray_day_2.2.png b/Spanish/images/projects/dom_min_project_countries_aray_day_2.2.png new file mode 100644 index 0000000..ca0e344 Binary files /dev/null and b/Spanish/images/projects/dom_min_project_countries_aray_day_2.2.png differ diff --git a/Spanish/images/projects/dom_min_project_day_7.1.gif b/Spanish/images/projects/dom_min_project_day_7.1.gif new file mode 100644 index 0000000..51bdadb Binary files /dev/null and b/Spanish/images/projects/dom_min_project_day_7.1.gif differ diff --git a/Spanish/images/projects/dom_min_project_day_number_generators_2.1.png b/Spanish/images/projects/dom_min_project_day_number_generators_2.1.png new file mode 100644 index 0000000..d69a6c2 Binary files /dev/null and b/Spanish/images/projects/dom_min_project_day_number_generators_2.1.png differ diff --git a/Spanish/images/projects/dom_min_project_keycode_day_3.2.gif b/Spanish/images/projects/dom_min_project_keycode_day_3.2.gif new file mode 100644 index 0000000..7c75c14 Binary files /dev/null and b/Spanish/images/projects/dom_min_project_keycode_day_3.2.gif differ diff --git a/Spanish/images/projects/dom_min_project_number_generator_day_3.1.gif b/Spanish/images/projects/dom_min_project_number_generator_day_3.1.gif new file mode 100644 index 0000000..59a8dd0 Binary files /dev/null and b/Spanish/images/projects/dom_min_project_number_generator_day_3.1.gif differ diff --git a/Spanish/images/projects/dom_min_project_solar_system_day_4.1.gif b/Spanish/images/projects/dom_min_project_solar_system_day_4.1.gif new file mode 100644 index 0000000..d88b04b Binary files /dev/null and b/Spanish/images/projects/dom_min_project_solar_system_day_4.1.gif differ diff --git a/Spanish/images/projects/dom_min_project_solar_system_day_4.1.mkv b/Spanish/images/projects/dom_min_project_solar_system_day_4.1.mkv new file mode 100644 index 0000000..1ed941c Binary files /dev/null and b/Spanish/images/projects/dom_min_project_solar_system_day_4.1.mkv differ diff --git a/Spanish/images/projects/dom_min_project_solar_system_day_4.1.mp4 b/Spanish/images/projects/dom_min_project_solar_system_day_4.1.mp4 new file mode 100644 index 0000000..69ce936 Binary files /dev/null and b/Spanish/images/projects/dom_min_project_solar_system_day_4.1.mp4 differ diff --git a/Spanish/images/projects/dom_mini_project_challenge_info_day_2.3.gif b/Spanish/images/projects/dom_mini_project_challenge_info_day_2.3.gif new file mode 100644 index 0000000..571ea6f Binary files /dev/null and b/Spanish/images/projects/dom_mini_project_challenge_info_day_2.3.gif differ diff --git a/Spanish/images/projects/dom_mini_project_challenge_info_day_2.3.png b/Spanish/images/projects/dom_mini_project_challenge_info_day_2.3.png new file mode 100644 index 0000000..3387bea Binary files /dev/null and b/Spanish/images/projects/dom_mini_project_challenge_info_day_2.3.png differ diff --git a/Spanish/images/projects/dom_mini_project_countries_day_6.1.gif b/Spanish/images/projects/dom_mini_project_countries_day_6.1.gif new file mode 100644 index 0000000..8a8f09a Binary files /dev/null and b/Spanish/images/projects/dom_mini_project_countries_day_6.1.gif differ diff --git a/Spanish/images/projects/dom_mini_project_countries_object_day_10.1.gif b/Spanish/images/projects/dom_mini_project_countries_object_day_10.1.gif new file mode 100644 index 0000000..03b1e35 Binary files /dev/null and b/Spanish/images/projects/dom_mini_project_countries_object_day_10.1.gif differ diff --git a/Spanish/images/projects/dom_mini_project_form_validation_day_10.2.1.png b/Spanish/images/projects/dom_mini_project_form_validation_day_10.2.1.png new file mode 100644 index 0000000..9d2c2b3 Binary files /dev/null and b/Spanish/images/projects/dom_mini_project_form_validation_day_10.2.1.png differ diff --git a/Spanish/images/projects/dom_mini_project_form_validation_day_10.2.png b/Spanish/images/projects/dom_mini_project_form_validation_day_10.2.png new file mode 100644 index 0000000..ca7cdd5 Binary files /dev/null and b/Spanish/images/projects/dom_mini_project_form_validation_day_10.2.png differ diff --git a/Spanish/images/projects/dom_mini_project_leaderboard_day_8.1.gif b/Spanish/images/projects/dom_mini_project_leaderboard_day_8.1.gif new file mode 100644 index 0000000..789d0cb Binary files /dev/null and b/Spanish/images/projects/dom_mini_project_leaderboard_day_8.1.gif differ diff --git a/Spanish/images/projects/dom_mini_project_leaderboard_day_8.1.png b/Spanish/images/projects/dom_mini_project_leaderboard_day_8.1.png new file mode 100644 index 0000000..2956fa0 Binary files /dev/null and b/Spanish/images/projects/dom_mini_project_leaderboard_day_8.1.png differ diff --git a/Spanish/images/projects/dom_mini_project_slider_day_7.1.gif b/Spanish/images/projects/dom_mini_project_slider_day_7.1.gif new file mode 100644 index 0000000..51bdadb Binary files /dev/null and b/Spanish/images/projects/dom_mini_project_slider_day_7.1.gif differ diff --git a/Spanish/images/raising_syntax_error.png b/Spanish/images/raising_syntax_error.png new file mode 100644 index 0000000..81f6245 Binary files /dev/null and b/Spanish/images/raising_syntax_error.png differ diff --git a/Spanish/images/regex.png b/Spanish/images/regex.png new file mode 100644 index 0000000..c7116b4 Binary files /dev/null and b/Spanish/images/regex.png differ diff --git a/Spanish/images/running_script.png b/Spanish/images/running_script.png new file mode 100644 index 0000000..deac13d Binary files /dev/null and b/Spanish/images/running_script.png differ diff --git a/Spanish/images/scripts_on_vscode.png b/Spanish/images/scripts_on_vscode.png new file mode 100644 index 0000000..f6257be Binary files /dev/null and b/Spanish/images/scripts_on_vscode.png differ diff --git a/Spanish/images/string_indexes.png b/Spanish/images/string_indexes.png new file mode 100644 index 0000000..cc2f638 Binary files /dev/null and b/Spanish/images/string_indexes.png differ diff --git a/Spanish/images/vscode.png b/Spanish/images/vscode.png new file mode 100644 index 0000000..724fc10 Binary files /dev/null and b/Spanish/images/vscode.png differ diff --git a/Spanish/images/vscode_ui.png b/Spanish/images/vscode_ui.png new file mode 100644 index 0000000..7210a08 Binary files /dev/null and b/Spanish/images/vscode_ui.png differ diff --git a/Spanish/images/web_storage.png b/Spanish/images/web_storage.png new file mode 100644 index 0000000..46f9311 Binary files /dev/null and b/Spanish/images/web_storage.png differ diff --git a/Spanish/readme.md b/Spanish/readme.md new file mode 100644 index 0000000..7df9958 --- /dev/null +++ b/Spanish/readme.md @@ -0,0 +1,550 @@ + +
    +

    30 Días de JavaScript

    + + + + + Twitter Follow + + + Autor: + Asabeneh Yetayeh
    + Enero de 2020 +
    + +
    + + 🇬🇧 [English](../readMe.md) + 🇪🇸 [Spanish](./readme.md) + 🇷🇺 [Russian](../RU/README.md) + +
    +
    + + +![Thirty Days Of JavaScript](./images/day_1_1.png) + + +[📔Día 1](#día-1) +- [📔Día 1](#día-1) + - [Introducción](#introducción) + - [Requerimientos](#requerimientos) + - [Preparación](#preparación) + - [Instala Node.js](#instala-nodejs) + - [Navegador](#navegador) + - [Instalando Google Chrome](#instalando-google-chrome) + - [Abriendo la consola de Google Chrome](#abriendo-la-consola-de-google-chrome) + - [Escribiendo el código en la consola del navegador](#escribiendo-el-código-en-la-consola-del-navegador) + - [Console.log](#consolelog) + - [Console.log con múltiples argumentos](#consolelog-con-múltiples-argumentos) + - [Comentario](#comentario) + - [Sintaxis](#sintaxis) + - [Aritmética](#aritmética) + - [Editor de código](#editor-de-código) + - [Instalando Visual Studio](#instalando-visual-studio) + - [Cómo usar Visual Studio Code](#cómo-usar-visual-studio-code) + - [Añadiendo JavaScript a una página web](#añadiendo-javascript-a-una-página-web) + - [Script en línea](#script-en-línea) + - [Script interno](#script-interno) + - [Script externo](#script-externo) + - [Múltiples Scripts externos](#múltiples-scripts-externos) + - [Introducción a los tipos de datos](#introducción-a-los-tipos-de-datos) + - [Números](#números) + - [Cadenas de texto](#cadenas-de-texto) + - [Booleanos](#booleanos) + - [Undefined](#undefined) + - [Null](#null) + - [Comprobando los tipos de datos](#comprobando-los-tipos-de-datos) + - [Comentarios](#comentarios) + - [Variables](#variables) +- [💻 Día 1: Ejercicios](#-día-1-ejercicios) + +# 📔Día 1 + +## Introducción + +**Felicidades** por decidir participar en el desafío de 30 días de JavaScript. En este desafío aprenderás todo lo que necesitas para ser un programador de JavaScript y los conceptos generales de la programación. Al final obtendrás un certificado de 30 días de JavaScript. Únete al [grupo de telegram](https://t.me/ThirtyDaysOfJavaScript). + +**30 días de JavaScript** es una guía tanto para principiantes como para desarrolladores avanzados. Bienvenido a JavaScript. Disfruto de usarlo y enseñarlo y espero que tú también. JavaScript es el lenguaje del navegador. + +En este tutorial de paso a paso, aprenderás JavaScript, el leguaje de programación más popular de la historia de la humanidad. Se usa para **agregar interactividad a las páginas web, para desarrollar aplicaciones móbiles, aplicaciones de desktop, juegos** y ahora también puede ser usado para el **aprendizaje automático** (machine learning) e **inteligencia artificial** (AI). Su popularidad ha incrementado en años recientes, siendo el lenguaje predominante por cuatro años consecutivos y el más usado en GitHub. + +## Requerimientos + +Ningún conocimiento previo es requerido para el siguiente desafío. Solo necesitarás: + +1. Motivación +2. Una computadora +3. Internet +4. Un navegador +5. Un editor de texto + +## Preparación + +Asumo que tienes motivación, un fuerte deseo de convertirte en un desarrollador, una computadora e internet. Si tienes todo esto, entonces lo tienes todo. + +### Instala Node.js + +Tal vez no lo necesites ahora pero si más adelante. Asi que instala [node.js](https://nodejs.org/en/) + +![Node download](./images/download_node.png) + +Luego de que se descargue, haz doble click e instálalo + + ![Install node](./images/install_node.png) + +Puedes comprobar si se ha instalado correctamente abriendo la terminal del ordenador + + asabeneh $ node -v + v12.14.0 + +Para el desafío estaremos utilizando la versión 12.14.0, la cual es la recomendada por node. + +### Navegador + +Existen muchos navegadores disponibles. Sin embargo, recomiendo especialmente Google Chrome. + +#### Instalando Google Chrome + +Instala [Google Chrome](https://www.google.com/chrome/) si aún no lo tienes. Podemos escribir un pequeño código JavaScript en la consola del navegador, pero no utilizamos la consola para desarrollar aplicaciones. + +![Google Chrome](./images/google_chrome.png) + +#### Abriendo la consola de Google Chrome + +Puedes abrir la consola de Google Chrome haciendo click en los tres puntos de la esquina superior derecha del navegador Chrome o utilizando un acceso directo. Yo prefiero usar los atajos. + +![Opening chrome](./images/opening_developer_tool.png) + +Para abrir la consola Chrome usando un atajo. + + Mac + Command+Option+I + + Windows: + Ctl+Shift+I + +![Opening console](./images/opening_chrome_console_shortcut.png) + +Después de abrir la consola de Google Chrome, intenta explorar los botones marcados. Pasaremos la mayor parte del tiempo aquí. La consola es el lugar donde va el código de JavaScript. El motor de la Consola de Google V8 cambia tu código JavaScript a código de máquina. Escribamos un código JavaScript en la consola de Google Chrome: + +![write code on console](./images/js_code_on_chrome_console.png) + +#### Escribiendo el código en la consola del navegador + +Podemos escribir cualquier código de JavaScript en la consola de Google o en la de cualquier navegador. Sin embargo, para este desafío, sólo nos centramos en la consola de Google Chrome. Abre la consola usando: + + Mac + Comando+Opción+I + + Windows: + Ctl+Mayúsculas+I + +##### Console.log + +Para escribir nuestro primer código de JavaScript, usamos una función incorporada, **console.log()**. Pasamos un argumento como datos de entrada, y la función muestra la salida. Pasamos 'Hola, Mundo' como datos de entrada o argumento en la función console.log(). + + console.log('¡Hola, Mundo!') + +##### Console.log con múltiples argumentos + +El console.log(param1, param2, param3), puede tomar múltiples argumentos. + +![console log multiple arguments](./images/console_log_multipl_arguments.png) + + console.log('Hola', 'Mundo', '!') + console.log('FELIZ', 'AÑO', 'NUEVO', 2020) + console.log('Bienvenido', 'a', 30, 'Días', 'de', 'JavaScript') + +Como pueden ver, en el código del fragmento de arriba, console.log() puede tomar múltiples argumentos. + +¡Felicidades! Escribiste tu primer código JavaScript usando _console.log()_. + +##### Comentario + +Podemos añadir comentarios a nuestro código. Los comentarios son muy importantes para hacer el código más legible y para dejar recordatorios en nuestro código. JavaScript no ejecuta la parte de comentarios de nuestro código. Cualquier hay texto que empiece con // en JavaScript es un comentario o cualquier cosa que encierre como esta /\* \*/ es un comentario. + +**Ejemplo: Comentario en una sola línea** + + // Este es el primer comentario + // Este es el segundo comentario + // Soy un comentario de una sola línea + +**Ejemplo: Comentario multilínea** + + /* Este es un comentario de varias líneas. + + Los comentarios multilínea pueden tomar múltiples líneas. + + JavaScript es el lenguaje de la web + */ + +##### Sintaxis + +JavaScript es un lenguaje de programación. Como resultado, tiene su sintaxis como otros lenguajes. Si no escribimos una sintaxis que JavaScript entienda, se producirán diferentes tipos de errores. Exploraremos diferentes tipos de errores de JavaScript más adelante. Por ahora, veamos los errores de sintaxis. + +![Error](./images/raising_syntax_error.png) + +Cometí un error deliberado. Como resultado, la consola produce un error de sintaxis. En realidad, la sintaxis es muy informativa. Informa sobre el tipo de error que cometimos. Leyendo la guía de retroalimentación de errores, podemos corregir la sintaxis y arreglar el problema. El proceso de identificar y eliminar errores de un programa se llama 'debugging'. Corrijamos los errores: + + console.log("¡Hola, Mundo!") + console.log('¡Hola, Mundo!') + +Hasta ahora, hemos visto cómo mostrar el texto usando un console.log(). Si imprimimos texto o cadena usando console.log(), el texto tiene que estar entre comillas simples, dobles o 'backtick' (``). **Ejemplo:** + + console.log("¡Hola, Mundo!") + console.log('¡Hola, Mundo!') + console.log(`Hola, Mundo!`) + +#### Aritmética + +Ahora, practiquemos más la escritura de códigos JavaScript usando console.log() en la consola de Google Chrome para los tipos de datos numéricos. Además del texto, también podemos hacer cálculos matemáticos usando JavaScript. Hagamos los siguientes cálculos sencillos. + +![Arithmetic](./images/arithmetic.png) + + console.log(2 + 3) // Adición + console.log(3 - 2) // Sustracción + console.log(2 * 3) // Multiplicación + console.log(3 / 2) // División + console.log(3 % 2) // Módulo - encontrar el resto + console.log(3 ** 2) // Exponencial + +### Editor de código + +Podemos escribir nuestros códigos en la consola del navegador, pero no será para proyectos más grandes. En un entorno de trabajo real, los desarrolladores utilizan diferentes editores para escribir sus códigos. En este desafío de 30 días de JavaScript, usaremos Visual Studio Code. + +#### Instalando Visual Studio + +Visual Studio es un editor de texto de código abierto muy popular. Recomendaría descargarlo, pero si estás a favor de otros editores, siéntete libre de seguir con lo que tienes. + +![Vscode](./images/vscode.png) + +Si ya instalaste Visual Studio Code, empezaremos a usarlo. + +#### Cómo usar Visual Studio Code + +Abre Visual Studio Code haciendo doble clic en el ícono de Visual Studio. Cuando lo abras, obtendrás este tipo de interfaz. Intenta interactuar con los iconos etiquetados. + +![Vscode ui](./images/vscode_ui.png) + +![Vscode add project](./images/adding_project_to_vscode.png) + +![Vscode open project](./images/opening_project_on_vscode.png) + +![script file](./images/scripts_on_vscode.png) + +![running script](./images/running_script.png) + +![coding running](./images/launched_on_new_tab.png) + +## Añadiendo JavaScript a una página web + +JavaScript puede ser añadido a una página web de tres maneras diferentes: + +- **_Script en línea ('Inline script')_** +- **_Script interno_** +- **_Script externo_** +- **_Múltiples scripts_** + +Las siguientes secciones muestran diferentes formas de añadir código JavaScript a nuestra página web. + +### Script en línea + +Crea una carpeta en tu escritorio y llámala 30DíasDeJS o en cualquier lugar y crea un archivo **_index.html_** en la carpeta del proyecto. Luego pega el siguiente código y ábrelo en un navegador, ya sea en [Chrome](https://www.google.com/chrome/). + + + + + 30DíasDeJS:Inline Script + + + + + + + +Ahora, escribiste tu primer inline script. Podemos crear un mensaje de alerta emergente usando la función integrada _alert()_. + +### Script interno + +El Script interno puede ser escrito en la cabecera del código _('head')_ o en el cuerpo _('body')_, pero es preferible ponerlo en el cuerpo del documento HTML. Primero, escribamos en la parte de la cabeza de la página. + + + + + 30DíasDeJS:Scripts Internos + + + + + + +Así es como escribimos el guión interno la mayor parte del tiempo. Escribir el código de JavaScript en la sección del body es el lugar más recomendado. Abre la consola del navegador para ver la respuesta del console.log() + + + + + 30DíasDeJS:Scripts Internos + + + + + + + +Abre la consola del navegador para ver la respuesta del console.log() + +![js code from vscode](./images/js_code_vscode.png) + +### Script externo + +Al igual que el script interno, el enlace del script externo puede estar en la cabecera del código ('head') o en el cuerpo ('body'), pero igualmente es recomendado ponerlo en el 'body'. Primero, debemos crear un archivo JavaScript externo con extensión .js. Cualquier archivo JavaScript termina con .js. Crea un archivo introduccion.js dentro del directorio del proyecto y escribe el siguiente código y enlaza este archivo .js en la parte inferior del cuerpo. + + console.log('Bienvenido a 30DaysOfJavaScript') + +**Script externo en la cabecera** + + + + + 30DíasDeJS:Scripts Externos + + + + + + +**Script externo en el cuerpo** + + + + + 30DíasDeJS:Scripts Externos + + + //Podría estar en la cabecera o en el cuerpo... + // Aquí está el lugar recomendado para poner el script externo + + + + +Abre la consola del navegador para ver la respuesta del console.log() + +### Múltiples Scripts externos + +Podemos enlazar múltiples archivos externos de JavaScript a una página web. Crea un archivo holamundo.js dentro de la carpeta 30DiasDeJS y escribe el siguiente código. + + console.log('¡Hola, Mundo!') + + + + + + Múltiples guiones externos + + + + + + + + +Tu archivo main.js debería estar por debajo de todos los otros scripts. Ten cuidado con tu ejercicio para entender esta línea. + +![Multiple Script](./images/multiple_script.png) + +## Introducción a los tipos de datos + +En JavaScript y también en otros lenguajes de programación, hay diferentes tipos de datos. Los siguientes son los tipos de datos primitivos de JavaScript: _Cadenas de texto ('string'), Números, Booleanos, undefined, Null_ y _Symbol_. + +### Números + +- Enteros: Números enteros (negativos, cero y positivos) Ejemplo: ... -3, -2, -1, 0, 1, 2, 3 ... +- Float: Números decimales Ejemplo ... -3.5, -2.25, -1.0, 0.0, 1.1, 2.2, 3.5 ... + +### Cadenas de texto + +Una colección de uno o más carácteres entre comillas. **Ejemplo:** + + "Asabeneh + "Finlandia + 'JavaScript es un hermoso lenguaje de programación'. + "Me encanta enseñar" + "Espero que estés disfrutando del primer día" + `También podemos crear una cadena usando un backtick` + +### Booleanos + +Un valor booleano es verdadero o falso. Cualquier comparación devuelve un valor booleano, que es verdadero o falso. + +Un tipo de datos booleano es un valor Verdadero o Falso. + +**Ejemplo:** + + true // si la luz está encendida, el valor es true + falso // si la luz está apagada, el valor es Falso + +### Undefined + +En JavaScript, si no asignamos un valor a una variable, el valor es indefinido. Además, si una función no devuelve nada, devuelve undefined. + + let nombre; + console.log(nombre); //no está definida, porque no está asignada a un valor todavía + +### Null + +Null en JavaScript significa un valor vacío/nulo. + + let valorVacio = null + +## Comprobando los tipos de datos + +Para comprobar el tipo de datos de un determinado valor, utilizamos el operador **'typeof'**. Véase el siguiente ejemplo. + + console.log(typeof 'Asabeneh') // string + console.log(typeof 5) // número + console.log(typeof true ) // boolean + console.log(typeof null) // tipo de objeto + console.log(typeof undefined) // undefined + +## Comentarios + +Los comentarios en JavaScript son similares a los de otros lenguajes de programación. Los comentarios son importantes para hacer tu código más legible. Hay dos maneras de comentar: + +- _Comentario en una sola línea_ +- _Comentario multilineal_ + + // comentando el código mismo con un solo comentario + // let nombre = 'Asabeneh'; comentario de una sola línea + // let apellido = 'Yetayeh'; comentario de una sola línea + +Comentario multilineal: + + /* + let ubicación = 'Helsinki'; + let edad = 100; + let casado = verdadero; + Este es un comentario de varias líneas + */ + +### Variables + +Las variables son contenedores de datos. Las variables se utilizan para almacenar datos en una ubicación de memoria. Cuando se declara una variable, se reserva una ubicación de memoria. Cuando se asigna una variable a un valor (data), el espacio de memoria se llena con esos datos. Para declarar una variable, usamos palabras clave _var_, _let_ o _const_. Hablaremos más sobre var, let y const en detalle en otras secciones (ámbito). Por ahora, la explicación anterior es suficiente. + +Para una variable que cambia en un momento diferente, usamos _let_. Si los datos no cambian en absoluto, usamos _const_. Por ejemplo, PI, nombre del país, gravedad no cambian, y podemos usar _const._ + +- El nombre de una variable en JavaScript no debe comenzar con un número. +- Un nombre de variable JavaScript no permite caracteres especiales excepto el signo de dólar y el guión bajo. +- Los nombres de las variables en JavaScript siguen una convención 'CamelCase'. +- El nombre de una variable no debe tener espacio entre palabras. + +Los siguientes son ejemplos válidos de variables JavaScript. + +Variables válidas en JavaScript: + + primerNombre + apellido + país + ciudadCapital + capital + edad + estaCasado + + nombre_de_pila + apellido + esta_casado + ciudad_capital + + num1 + num_1 + _num_1 + $num1 + año2020 + año_2020 + +camelCase es convencional en JavaScript. En este material, usaremos variables de CamelCase. + +Variables inválidas: + + primer-nombre + 1_numero + num_#_1 + +Declaremos las variables con diferentes tipos de datos. Para declarar una variable, necesitamos usar la palabra clave let o const antes del nombre de la variable. Después del nombre de la variable, escribimos un signo igual (operador de asignación), y un valor. + + # Sintaxis + let nombreDeLaVariable = valor + +**Ejemplos: Variables** + + // Declarando diferentes variables de diferentes tipos de datos + let nombre = 'Asabeneh' // nombre de una persona + let apellido = 'Yetayeh' // apellido de una persona + let pais = 'Finland' // país + let ciudad = 'Helsinki' // ciudad capital + let edad = 100 // edad en años + let estaCasado = true + + console.log(nombre, apellido, país, ciudad, edad, estáCasado) + + + Asabeneh Yetayeh Finlandia Helsinki 100 True + + // Declarando variables con valores numéricos + let edad = 100 // edad en años + const constante = 9,81 // gravedad terrestre en m/s2 + const puntoDeEbullición = 100 // punto de ebullición del agua, temperatura en oC + const PI = 3.14 // constante geométrica + + console.log(gravedad, punto de ebullición, PI) + + + 9.81 100 3.14 + + + // Las variables también pueden ser declaradas en una línea separada por una coma + let nombre = 'Asabeneh', // nombre de una persona + trabajo = 'profesor', + viveEn = 'Finlandia'; + console.log(nombre, trabajo, viveEn); + + + Asabeneh profesor de Finlandia + +Cuando ejecutas los archivos en la carpeta Día_1 deberías obtener esto: + +![Day one](./images/day_1.png) + +🌕 Eres increíble. Acabas de completar el desafío del día 1 y estás en camino a la grandeza. Ahora haz algunos ejercicios para tu cerebro y para tus músculos. + +# 💻 Día 1: Ejercicios + +1. Escribe un comentario de una sola línea que diga _"los comentarios pueden hacer que el código sea legible"_ + +2. Escribe otro comentario que diga, _"Bienvenido a 30DaysOfJavaScript"_ + +3. Escribe un comentario multilínea que diga, _"Los comentarios pueden hacer el código legible, fácil de usar e informativo"_ + +4. Crea un archivo variable.js y declarar variables y asignar tipos de datos string, booleanos, indefinidos y nulos + +5. Crea el archivo datatypes.js y utilizar el operador **_"typeof"_** de JavaScript para comprobar los diferentes tipos de datos. Comprueba el tipo de datos de cada variable + +6. Declara cuatro variables sin asignar valores + +7. Declara cuatro variables con valores asignados + +8. Declara variables para almacenar su nombre, apellido, estado civil, país y edad en múltiples líneas + +9. Declara variables para almacenar su nombre, apellido, estado civil, país y edad en una sola línea + +10. Declara dos variables _miEdad_ y _tuEdad_ y asígneles valores iniciales y regístrese en la consola del navegador. + + Tengo 25 años. + Tú tienes 30 años. + + 🎉 ¡FELICIDADES! 🎉 diff --git a/images/banners/day_1_16.png b/images/banners/day_1_16.png new file mode 100644 index 0000000..d116060 Binary files /dev/null and b/images/banners/day_1_16.png differ diff --git a/images/banners/day_1_17.png b/images/banners/day_1_17.png new file mode 100644 index 0000000..69cf7ae Binary files /dev/null and b/images/banners/day_1_17.png differ diff --git a/images/banners/day_1_18.png b/images/banners/day_1_18.png new file mode 100644 index 0000000..8b69340 Binary files /dev/null and b/images/banners/day_1_18.png differ diff --git a/images/banners/day_1_19.png b/images/banners/day_1_19.png new file mode 100644 index 0000000..2a785c9 Binary files /dev/null and b/images/banners/day_1_19.png differ diff --git a/images/banners/day_1_20.png b/images/banners/day_1_20.png new file mode 100644 index 0000000..befe1fc Binary files /dev/null and b/images/banners/day_1_20.png differ diff --git a/images/banners/day_1_21.png b/images/banners/day_1_21.png new file mode 100644 index 0000000..634d1eb Binary files /dev/null and b/images/banners/day_1_21.png differ diff --git a/images/banners/day_1_22.png b/images/banners/day_1_22.png new file mode 100644 index 0000000..81e33d9 Binary files /dev/null and b/images/banners/day_1_22.png differ diff --git a/images/banners/day_1_23.png b/images/banners/day_1_23.png new file mode 100644 index 0000000..ceb0321 Binary files /dev/null and b/images/banners/day_1_23.png differ diff --git a/images/banners/day_1_24.png b/images/banners/day_1_24.png new file mode 100644 index 0000000..9c8ec46 Binary files /dev/null and b/images/banners/day_1_24.png differ diff --git a/images/banners/day_1_25.png b/images/banners/day_1_25.png new file mode 100644 index 0000000..60a211e Binary files /dev/null and b/images/banners/day_1_25.png differ diff --git a/images/banners/day_1_26.png b/images/banners/day_1_26.png new file mode 100644 index 0000000..f187f2c Binary files /dev/null and b/images/banners/day_1_26.png differ diff --git a/images/banners/day_1_27.png b/images/banners/day_1_27.png new file mode 100644 index 0000000..8637069 Binary files /dev/null and b/images/banners/day_1_27.png differ diff --git a/images/banners/day_1_28.png b/images/banners/day_1_28.png new file mode 100644 index 0000000..1858aca Binary files /dev/null and b/images/banners/day_1_28.png differ diff --git a/images/banners/day_1_29.png b/images/banners/day_1_29.png new file mode 100644 index 0000000..959ee36 Binary files /dev/null and b/images/banners/day_1_29.png differ diff --git a/images/banners/day_1_30.png b/images/banners/day_1_30.png new file mode 100644 index 0000000..18a77c4 Binary files /dev/null and b/images/banners/day_1_30.png differ diff --git a/images/become_patreon.png b/images/become_patreon.png new file mode 100644 index 0000000..7de852e Binary files /dev/null and b/images/become_patreon.png differ diff --git a/images/local_storage.png b/images/local_storage.png new file mode 100644 index 0000000..0876852 Binary files /dev/null and b/images/local_storage.png differ diff --git a/images/projects/congratulations.gif b/images/projects/congratulations.gif new file mode 100644 index 0000000..cddd6c4 Binary files /dev/null and b/images/projects/congratulations.gif differ diff --git a/images/projects/dom_min_project_30DaysOfJavaScript_color_changing_day_9.1.gif b/images/projects/dom_min_project_30DaysOfJavaScript_color_changing_day_9.1.gif new file mode 100644 index 0000000..c8d2f2b Binary files /dev/null and b/images/projects/dom_min_project_30DaysOfJavaScript_color_changing_day_9.1.gif differ diff --git a/images/projects/dom_min_project_bar_graph_day_5.1.gif b/images/projects/dom_min_project_bar_graph_day_5.1.gif new file mode 100644 index 0000000..a7d7962 Binary files /dev/null and b/images/projects/dom_min_project_bar_graph_day_5.1.gif differ diff --git a/images/projects/dom_min_project_bar_graph_day_5.1.png b/images/projects/dom_min_project_bar_graph_day_5.1.png new file mode 100644 index 0000000..0b6ccf7 Binary files /dev/null and b/images/projects/dom_min_project_bar_graph_day_5.1.png differ diff --git a/images/projects/dom_min_project_challenge_info_day_1.1.gif b/images/projects/dom_min_project_challenge_info_day_1.1.gif new file mode 100644 index 0000000..0551771 Binary files /dev/null and b/images/projects/dom_min_project_challenge_info_day_1.1.gif differ diff --git a/images/projects/dom_min_project_challenge_info_day_1.1.png b/images/projects/dom_min_project_challenge_info_day_1.1.png new file mode 100644 index 0000000..01a8d4f Binary files /dev/null and b/images/projects/dom_min_project_challenge_info_day_1.1.png differ diff --git a/images/projects/dom_min_project_countries_aray_day_2.2.png b/images/projects/dom_min_project_countries_aray_day_2.2.png new file mode 100644 index 0000000..ca0e344 Binary files /dev/null and b/images/projects/dom_min_project_countries_aray_day_2.2.png differ diff --git a/images/projects/dom_min_project_day_7.1.gif b/images/projects/dom_min_project_day_7.1.gif new file mode 100644 index 0000000..51bdadb Binary files /dev/null and b/images/projects/dom_min_project_day_7.1.gif differ diff --git a/images/projects/dom_min_project_day_number_generators_2.1.png b/images/projects/dom_min_project_day_number_generators_2.1.png new file mode 100644 index 0000000..d69a6c2 Binary files /dev/null and b/images/projects/dom_min_project_day_number_generators_2.1.png differ diff --git a/images/projects/dom_min_project_keycode_day_3.2.gif b/images/projects/dom_min_project_keycode_day_3.2.gif new file mode 100644 index 0000000..7c75c14 Binary files /dev/null and b/images/projects/dom_min_project_keycode_day_3.2.gif differ diff --git a/images/projects/dom_min_project_number_generator_day_3.1.gif b/images/projects/dom_min_project_number_generator_day_3.1.gif new file mode 100644 index 0000000..59a8dd0 Binary files /dev/null and b/images/projects/dom_min_project_number_generator_day_3.1.gif differ diff --git a/images/projects/dom_min_project_solar_system_day_4.1.gif b/images/projects/dom_min_project_solar_system_day_4.1.gif new file mode 100644 index 0000000..d88b04b Binary files /dev/null and b/images/projects/dom_min_project_solar_system_day_4.1.gif differ diff --git a/images/projects/dom_min_project_solar_system_day_4.1.mkv b/images/projects/dom_min_project_solar_system_day_4.1.mkv new file mode 100644 index 0000000..1ed941c Binary files /dev/null and b/images/projects/dom_min_project_solar_system_day_4.1.mkv differ diff --git a/images/projects/dom_min_project_solar_system_day_4.1.mp4 b/images/projects/dom_min_project_solar_system_day_4.1.mp4 new file mode 100644 index 0000000..69ce936 Binary files /dev/null and b/images/projects/dom_min_project_solar_system_day_4.1.mp4 differ diff --git a/images/projects/dom_mini_project_challenge_info_day_2.3.gif b/images/projects/dom_mini_project_challenge_info_day_2.3.gif new file mode 100644 index 0000000..571ea6f Binary files /dev/null and b/images/projects/dom_mini_project_challenge_info_day_2.3.gif differ diff --git a/images/projects/dom_mini_project_challenge_info_day_2.3.png b/images/projects/dom_mini_project_challenge_info_day_2.3.png new file mode 100644 index 0000000..3387bea Binary files /dev/null and b/images/projects/dom_mini_project_challenge_info_day_2.3.png differ diff --git a/images/projects/dom_mini_project_countries_day_6.1.gif b/images/projects/dom_mini_project_countries_day_6.1.gif new file mode 100644 index 0000000..8a8f09a Binary files /dev/null and b/images/projects/dom_mini_project_countries_day_6.1.gif differ diff --git a/images/projects/dom_mini_project_countries_object_day_10.1.gif b/images/projects/dom_mini_project_countries_object_day_10.1.gif new file mode 100644 index 0000000..03b1e35 Binary files /dev/null and b/images/projects/dom_mini_project_countries_object_day_10.1.gif differ diff --git a/images/projects/dom_mini_project_form_validation_day_10.2.1.png b/images/projects/dom_mini_project_form_validation_day_10.2.1.png new file mode 100644 index 0000000..9d2c2b3 Binary files /dev/null and b/images/projects/dom_mini_project_form_validation_day_10.2.1.png differ diff --git a/images/projects/dom_mini_project_form_validation_day_10.2.png b/images/projects/dom_mini_project_form_validation_day_10.2.png new file mode 100644 index 0000000..ca7cdd5 Binary files /dev/null and b/images/projects/dom_mini_project_form_validation_day_10.2.png differ diff --git a/images/projects/dom_mini_project_leaderboard_day_8.1.gif b/images/projects/dom_mini_project_leaderboard_day_8.1.gif new file mode 100644 index 0000000..789d0cb Binary files /dev/null and b/images/projects/dom_mini_project_leaderboard_day_8.1.gif differ diff --git a/images/projects/dom_mini_project_leaderboard_day_8.1.png b/images/projects/dom_mini_project_leaderboard_day_8.1.png new file mode 100644 index 0000000..2956fa0 Binary files /dev/null and b/images/projects/dom_mini_project_leaderboard_day_8.1.png differ diff --git a/images/projects/dom_mini_project_slider_day_7.1.gif b/images/projects/dom_mini_project_slider_day_7.1.gif new file mode 100644 index 0000000..51bdadb Binary files /dev/null and b/images/projects/dom_mini_project_slider_day_7.1.gif differ diff --git a/images/regex.png b/images/regex.png new file mode 100644 index 0000000..c7116b4 Binary files /dev/null and b/images/regex.png differ diff --git a/images/vsc_live_server.png b/images/vsc_live_server.png new file mode 100644 index 0000000..75509f2 Binary files /dev/null and b/images/vsc_live_server.png differ diff --git a/images/web_storage.png b/images/web_storage.png new file mode 100644 index 0000000..46f9311 Binary files /dev/null and b/images/web_storage.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..14e41c3 --- /dev/null +++ b/index.html @@ -0,0 +1,128 @@ + + + + + Document Object Model:30 Days Of JavaScript + + + + + + +
    +

    Asabeneh Yetayeh challenges in 2020

    +

    30DaysOfJavaScript Challenge

    +

    +
      +
    • 30DaysOfPython Challenge Done
    • +
    • 30DaysOfJavaScript Challenge Ongoing
    • +
    • 30DaysOfReact Challenge Coming
    • +
    • 30DaysOfReactNative Challenge Coming
    • +
    • 30DaysOfFullStack Challenge Coming
    • +
    • 30DaysOfDataAnalysis Challenge Coming
    • +
    • 30DaysOfMachineLearning Challenge Coming
    • +
    +
    + + + + + \ No newline at end of file diff --git a/readMe.md b/readMe.md index 7993797..0cfbb26 100644 --- a/readMe.md +++ b/readMe.md @@ -1,5 +1,43 @@ +# 30 Days Of JavaScript + +| # Day | Topics | +|-----------|:-------------------------------------------------------------------------------------------------------------: | +| 01 | [Introduction](./readMe.md) | +| 02 | [Data Types](./02_Day_Data_types/02_day_data_types.md) | +| 03 | [Booleans, Operators, Date](./03_Day_Booleans_operators_date/03_booleans_operators_date.md) | +| 04 | [Conditionals](./04_Day_Conditionals/04_day_conditionals.md)| +| 05 | [Arrays](./05_Day_Arrays/05_day_arrays.md) | +| 06 | [Loops](./06_Day_Loops/06_day_loops.md) | +| 07 | [Functions](./07_Day_Functions/07_day_functions.md) | +| 08 | [Objects](./08_Day_Objects/08_day_objects.md) | +| 09 | [Higher Order Functions](./09_Day_Higher_order_functions/09_day_higher_order_functions.md) | +| 10 | [Sets and Maps](./10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md) | +| 11 | [Destructuring and Spreading](./11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md) | +| 12 | [Regular Expressions](./12_Day_Regular_expressions/12_day_regular_expressions.md) | +| 13 | [Console Object Methods](./13_Day_Console_object_methods/13_day_console_object_methods.md)| +| 14 | [Error Handling](./14_Day_Error_handling/14_day_error_handling.md)| +| 15 | [Classes](./15_Day_Classes/15_day_classes.md) | +| 16 | [JSON](./16_Day_JSON/16_day_json.md) | +| 17 | [Web Storages](./17_Day_Web_storages/17_day_web_storages.md)| +| 18 | [Promises](./18_Day_Promises/18_day_promises.md)| +| 19 | [Closure](./19_Day_Closures/19_day_closures.md) | +| 20 | [Writing Clean Code](./20_Day_Writing_clean_codes/20_day_writing_clean_codes.md) | +| 21 | [DOM](./21_Day_DOM/21_day_dom.md) | +| 22 | [Manipulating DOM Object](./22_Day_Manipulating_DOM_object/22_day_manipulating_DOM_object.md) | +| 23 | [Event Listeners](./23_Day_Event_listeners/23_day_event_listeners.md)| +| 24 | [Mini Project: Solar System](./24_Day_Project_solar_system/24_day_project_solar_system.md) | +| 25 | [Mini Project: World Countries Data Visulalization 1](./25_Day_World_countries_data_visualization_1/25_day_world_countries_data_visualization_1.md) | +| 26 | [Mini Project: World Countries Data Visulalization 2](./26_Day_World_countries_data_visualization_2/26_day_world_countries_data_visualization_2.md) | +| 27 | [Mini Project: Portfolio](./27_Day_Mini_project_portfolio/27_day_mini_project_portfolio.md) | +| 28 | [Mini Project: Leaderboard](./28_Day_Mini_project_leaderboard/28_day_mini_project_leaderboard.md) | +| 29 | [Mini Project:Animating characters](./29_Day_Mini_project_animating_characters/29_day_mini_project_animating_characters.md) | +| 30 | [Final Projects](./30_Day_Mini_project_final/30_day_mini_project_final.md) | + +🧡🧡🧡 HAPPY CODING 🧡🧡🧡 + +
    -

    30 Days Of JavaScript

    +

    30 Days Of JavaScript: Introduction

    @@ -11,13 +49,30 @@ Asabeneh Yetayeh
    January, 2020 +
    + + 🇬🇧 [English](./readMe.md) + 🇪🇸 [Spanish](./Spanish/readme.md) + 🇷🇺 [Russian](./RU/README.md) + +
    + +
    -[Day 2 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/02_Day/02_day_data_types.md) +
    + +Support [**Asabeneh**](https://www.patreon.com/asabeneh?fan_landing=true) to create more educational materials +[become-asabeneh-patreon](https://www.patreon.com/asabeneh?fan_landing=true) + +
    + +[Day 2 >>](./02_Day_Data_types/02_day_data_types.md) ![Thirty Days Of JavaScript](./images/day_1_1.png) -- [📔Day 1](#%f0%9f%93%94day-1) +- [30 Days Of JavaScript](#30-days-of-javascript) +- [📔Day 1](#day-1) - [Introduction](#introduction) - [Requirements](#requirements) - [Setup](#setup) @@ -25,43 +80,43 @@ - [Browser](#browser) - [Installing Google Chrome](#installing-google-chrome) - [Opening Google Chrome Console](#opening-google-chrome-console) - - [Writing Code on browser Console](#writing-code-on-browser-console) + - [Writing Code on Browser Console](#writing-code-on-browser-console) - [Console.log](#consolelog) - - [Console.log with multiple arguments](#consolelog-with-multiple-arguments) + - [Console.log with Multiple Arguments](#consolelog-with-multiple-arguments) - [Comment](#comment) - [Syntax](#syntax) - [Arithmetics](#arithmetics) - [Code Editor](#code-editor) - [Installing Visual Studio Code](#installing-visual-studio-code) - - [How to use visual studio code](#how-to-use-visual-studio-code) - - [Adding JavaScript to a web page](#adding-javascript-to-a-web-page) + - [How to Use Visual Studio Code](#how-to-use-visual-studio-code) + - [Adding JavaScript to a Web Page](#adding-javascript-to-a-web-page) - [Inline Script](#inline-script) - - [Internal script](#internal-script) - - [External script](#external-script) - - [Multiple External scripts](#multiple-external-scripts) + - [Internal Script](#internal-script) + - [External Script](#external-script) + - [Multiple External Scripts](#multiple-external-scripts) - [Introduction to Data types](#introduction-to-data-types) - [Number](#number) - [String](#string) - [Booleans](#booleans) - [Undefined](#undefined) - [Null](#null) - - [Checking Data types](#checking-data-types) - - [Comments](#comments) + - [Checking Data Types](#checking-data-types) + - [Comments Again](#comments-again) - [Variables](#variables) -- [💻 Day 1: Exercises](#%f0%9f%92%bb-day-1-exercises) +- [💻 Day 1: Exercises](#-day-1-exercises) # 📔Day 1 ## Introduction -**Congratulations** for deciding to participate in a 30 days of JavaScript programming challenge . In this challenge you will learn everything you need to be a JavaScript programmer and in general the whole concepts of programming. In the end of the challenge you will get a 30DaysOfJavaScript programming challenge certificate. Join the [telegram group](https://t.me/ThirtyDaysOfJavaScript). +**Congratulations** for deciding to participate in 30 days of JavaScript programming challenge. In this challenge you will learn everything you need to be a JavaScript programmer, and in general, the whole concept of programming. In the end of the challenge you will get a 30DaysOfJavaScript programming challenge completion certificate. In case you need help or if you would like to help others you may join the [telegram group](https://t.me/ThirtyDaysOfJavaScript). -**A 30DaysOfJavaScript** challenge is a guide for both beginners and advanced JavaScript developers. Welcome to JavaScript. I enjoy using and teaching JavaScript and I hope you will do so. JavaScript is the language of the browser. +**A 30DaysOfJavaScript** challenge is a guide for both beginners and advanced JavaScript developers. Welcome to JavaScript. I enjoy using and teaching JavaScript and I hope you will do so too. JavaScript is the language of the web. In this step by step tutorial, you will learn JavaScript, the most popular programming language in the history of mankind. You use JavaScript **_to add interactivity to websites, to develop mobile apps, desktop applications, games_** and nowadays JavaScript can be used for **_machine learning_** and **_AI_**. **_JavaScript (JS)_** has increased in popularity in recent years and has been the leading -programming language for four consecutive years and is the most used programming language on +programming language for six consecutive years and is the most used programming language on Github. ## Requirements @@ -76,11 +131,11 @@ No prior knowledge of programming is required to follow this challenge. You need ## Setup -I believe you have the motivation and a strong desire to be a developer, computer and Internet. If you have those, then you have everything. +I believe you have the motivation and a strong desire to be a developer, computer and Internet. If you have those, then you have everything to get started. ### Install Node.js -You may not need it right now but you may need it for later. Install [node.js](https://nodejs.org/en/). +You may not need node.js right now but you may need it for later. Install [node.js](https://nodejs.org/en/). ![Node download](images/download_node.png) @@ -88,14 +143,14 @@ After downloading double click and install ![Install node](images/install_node.png) -We can check if node is installed in our local machine by opening our device terminal or command prompt. +We can check if node is installed on our local machine by opening our device terminal or command prompt. ```sh asabeneh $ node -v v12.14.0 ``` -I am using node version 12.14.0, which is the recommended version of node. +When making this tutorial I was using node version 12.14.0, but now the recommended version of node.js for download is 12.17.0. ### Browser @@ -109,18 +164,18 @@ Install [google chrome](https://www.google.com/chrome/) if you do not have one y #### Opening Google Chrome Console -You can open Google Chrome either by clicking three dots at the top right corner of the Chrome browser or using a shortcut. I prefer using shortcuts. +You can open Google Chrome console either by clicking three dots at the top right corner of the browser, selecting _More tools -> Developer tools_ or using a keyboard shortcut. I prefer using shortcuts. ![Opening chrome](images/opening_developer_tool.png) -To open the Chrome console using a short cut. +To open the Chrome console using a keyboard shortcut. ```sh Mac -Command+Option+I +Command+Option+J -Windows: -Ctl+Shift+I +Windows/Linux: +Ctl+Shift+J ``` ![Opening console](images/opening_chrome_console_shortcut.png) @@ -130,7 +185,7 @@ Let us write a JavaScript code on the Google Chrome console: ![write code on console](./images/js_code_on_chrome_console.png) -#### Writing Code on browser Console +#### Writing Code on Browser Console We can write any JavaScript code on the Google console or any browser console. However, for this challenge, we only focus on Google Chrome console. Open the console using: @@ -144,13 +199,13 @@ Ctl+Shift+I ##### Console.log -To write our first JavaScript code, we used a builtin function **console.log()**. We passed an argument as input data, and the function displays the output. We passed 'Hello, World' as input data or argument in the console.log() function. +To write our first JavaScript code, we used a built-in function **console.log()**. We passed an argument as input data, and the function displays the output. We passed 'Hello, World' as input data or argument in the console.log() function. ```js console.log('Hello, World!') ``` -##### Console.log with multiple arguments +##### Console.log with Multiple Arguments The console.log(param1, param2, param3), can take multiple arguments. @@ -162,13 +217,13 @@ console.log('HAPPY', 'NEW', 'YEAR', 2020) console.log('Welcome', 'to', 30, 'Days', 'Of', 'JavaScript') ``` -As you can see from the above snippet code, *console.log()* can take multiple arguments. +As you can see from the snippet code above, *console.log()* can take multiple arguments. Congratulations! You wrote your first JavaScript code using *console.log()*. ##### Comment -We add comments to our code. Comments are very important to make code more readable and to leave remarks in our code. JavaScript does not execute the comment part of our code. Any text starts with // in JavaScript is a comment or anything enclose like this /* */ is a comment. +We add comments to our code. Comments are very important to make code more readable and to leave remarks in our code. JavaScript does not execute the comment part of our code. Any text line starting with // in JavaScript is a comment or anything enclosed like this /* */ is a comment. **Example: Single Line Comment** @@ -186,7 +241,7 @@ We add comments to our code. Comments are very important to make code more reada ##### Syntax -JavaScript is a programming language. As a result, it has its syntax like other programming languages. If we do not write a syntax that JavaScript understands, it will raise different types of errors. We will explore different kinds of JavaScript errors later. For now, let us see syntax errors. +Programming languages are similar to human languages. English language or any other language uses words, phrases, sentences,compound sentences and other more to convey a meaningful message. The English meaning of syntax is *the arrangement of words and phrases to create well-formed sentences in a language*. The technical definition of syntax is *the structure of statements in a computer language.* Programing languages have syntax. JavaScript is a programming language and like other programming languages it has its own syntax. If we do not write a syntax that JavaScript understands, it will raise different types of errors. We will explore different kinds of JavaScript errors later. For now, let us see syntax errors. ![Error](images/raising_syntax_error.png) @@ -197,7 +252,7 @@ console.log("Hello, World!") console.log('Hello, World!') ``` -So far, we saw how to display text using a *console.log()*. If we are printing text or string using *console.log()*, the text has to be under the single, double, or backtick. +So far, we saw how to display text using a *console.log()*. If we are printing text or string using *console.log()*, the text has to be under the single quote, double quote, or a backtick quote. **Example:** ```js @@ -219,24 +274,24 @@ console.log(3 - 2) // Subtraction console.log(2 * 3) // Multiplication console.log(3 / 2) // Division console.log(3 % 2) // Modulus - finding remainder -console.log(3 ** 2) // Exponential +console.log(3 ** 2) // Exponentiation 3 ** 2 == 3 * 3 ``` ### Code Editor -We can write our codes on the browser console, but it won't be for bigger projects. In a real working environment, developers use different code editors to write their codes. In this 30 days python JavaScript challenge, we will use visual studio code. +We can write our codes on the browser console, but it won't do for bigger projects. In a real working environment, developers use different code editors to write their codes. In this 30 days JavaScript challenge, we will use Visual Studio Code. #### Installing Visual Studio Code -VVisual studio code is a very popular open-source text editor. I would recommend to [download](https://code.visualstudio.com/) visual studio code, but if you are in favor of other editors, feel free to follow with what you have. +Visual studio code is a very popular open-source text editor. I would recommend to [download Visual Studio Code](https://code.visualstudio.com/), but if you are in favor of other editors, feel free to follow with what you have. ![Vscode](images/vscode.png) -If you installed visual studio code, let us start using it. +If you installed Visual Studio Code, let us start using it. -#### How to use visual studio code +#### How to Use Visual Studio Code -Open the visual studio code by double-clicking the visual studio icon. When you open it, you will get this kind of interface. Try to interact with the labeled icons. +Open the Visual Studio Code by double-clicking its icon. When you open it, you will get this kind of interface. Try to interact with the labeled icons. ![Vscode ui](./images/vscode_ui.png) @@ -246,11 +301,13 @@ Open the visual studio code by double-clicking the visual studio icon. When you ![script file](images/scripts_on_vscode.png) +![Installing Live Server](images/vsc_live_server.png) + ![running script](./images/running_script.png) ![coding running](./images/launched_on_new_tab.png) -## Adding JavaScript to a web page +## Adding JavaScript to a Web Page JavaScript can be added to a web page in three different ways: - **_Inline script_** @@ -262,7 +319,7 @@ The following sections show different ways of adding JavaScript code to your web ### Inline Script -Create a folder on your desktop and call it 30DaysOfJS or in any location and create an **_index.html_** file in the project folder. Then paste the following code and open it in a browser, either in [Chrome](https://www.google.com/chrome/). +Create a folder on your desktop and call it 30DaysOfJS or in any location and create an **_index.html_** file in the project folder. Then paste the following code and open it in a browser, for example [Chrome](https://www.google.com/chrome/). ```html @@ -278,7 +335,7 @@ Create a folder on your desktop and call it 30DaysOfJS or in any location and c Now, you wrote your first inline script. We can create a pop up alert message using the built-in *alert()* function. -### Internal script +### Internal Script The internal script can be written in the _head_ or the _body_, but it is preferred to put it on the body of the HTML document. First, let us write on the head part of the page. @@ -297,7 +354,7 @@ First, let us write on the head part of the page. ``` -This is how we write the internal script most of the time. Writing the JavaScript code in the body section is the most preferred place. Open the browser console to see the output from the console.log() +This is how we write an internal script most of the time. Writing the JavaScript code in the body section is the most preferred option. Open the browser console to see the output from the console.log() ```html @@ -318,16 +375,16 @@ Open the browser console to see the output from the console.log() ![js code from vscode](./images/js_code_vscode.png) -### External script +### External Script Similar to the internal script, the external script link can be on the header or body, but it is preferred to put it in the body. -First, we should create an external JavaScript file with .js extension. Any JavaScript file ends with .js. Create a file introduction.js inside your project directory and write the following code and link this .js file at the bottom of the body. +First, we should create an external JavaScript file with .js extension. All files ending with .js extension are JavaScript files. Create a file introduction.js inside your project directory and write the following code and link this .js file at the bottom of the body. ```js console.log('Welcome to 30DaysOfJavaScript') ``` -External scripts in the head +External scripts in the _head_: ```html @@ -341,7 +398,7 @@ External scripts in the head ``` -External scripts in the body +External scripts in the _body_: ```html @@ -359,7 +416,7 @@ External scripts in the body Open the browser console to see the output from the console.log() -### Multiple External scripts +### Multiple External Scripts We can link multiple external JavaScript files to a web page. Create a helloworld.js file inside the 30DaysOfJS folder and write the following code. @@ -382,7 +439,7 @@ console.log('Hello, World!') ``` -Your main.js file should be below all other scripts. Watch out your exercise needs to understand this line. +*Your main.js file should be below all other scripts*. It is very important to remember this. ![Multiple Script](./images/multiple_script.png) @@ -392,7 +449,7 @@ In JavaScript and also other programming languages, there are different kinds of ### Number -- Integer: Integer(negative, zero and positive) numbers +- Integer: Integer (negative, zero and positive) numbers Example: ... -3, -2, -1, 0, 1, 2, 3 ... - Float: Decimal number @@ -401,7 +458,7 @@ In JavaScript and also other programming languages, there are different kinds of ### String -A collection of one or more characters under a single quote, double-quote, or backtick. +A collection of one or more characters under a single quote, double quote, or backtick quote. **Example:** ```js @@ -411,19 +468,20 @@ A collection of one or more characters under a single quote, double-quote, or ba "I love teaching" 'I hope you are enjoying the first day' `We can also create a string using a backtick` +'A string could be just as small as one character as big as many pages' ``` ### Booleans -A boolean value is either true or false. Any comparisons return a boolean value, which is either true or false. +A boolean value is either True or False. Any comparisons return a boolean value, which is either true or false. -A boolean data type is either a True or False value. +A boolean data type is either a true or false value. **Example:** ```js true // if the light on ,the value is true - false // if the light off, the value is False + false // if the light off, the value is false ``` ### Undefined @@ -443,9 +501,9 @@ Null in JavaScript means an empty value. let emptyValue = null ``` -## Checking Data types +## Checking Data Types -To check the data type of a certain data type, we use the **typeof** operator. See the following example. +To check the data type of a certain variable, we use the **typeof** operator. See the following example. ```js console.log(typeof 'Asabeneh') // string @@ -455,9 +513,9 @@ console.log(typeof null) // object type console.log(typeof undefined) // undefined ``` -## Comments +## Comments Again -Commenting in JavaScript is similar to other programming languages. Comments are important in making your make code more readable. +Reminding, that commenting in JavaScript is similar to other programming languages. Comments are important in making your make code more readable. There are two ways of commenting: - _Single line commenting_ @@ -484,7 +542,9 @@ Multiline commenting: Variables are _containers_ of data. Variables used to _store_ data in a memory location. When a variable is declared, a memory location is reserved. When a variable is assigned to a value (data), the memory space will be filled with that data. To declare a variable, we use _var_, _let_, or _const_ keywords. We will talk more about var, let, and const in detail in other sections (scope). For now, the above explanation is enough. -For a variable that changes at a different time, we use _let_. If the data does not change at all, we use _const_. For example, PI, country name, gravity do no change, and we can use *const*. +For a variable that changes at a different time, we use _let_. If the data does not change at all, we use _const_. For example, PI, country name, gravity do no change, and we can use *const*. We will not use var in this challenge and I don't recommend you to use it. It is error prone way of declaring variable it has lots of leak. + +A valid JavaScript - A JavaScript variable name should not begin with a number. - A JavaScript variable name does not allow special characters except dollar sign and underscore. @@ -505,7 +565,7 @@ Valid variables in JavaScript: first_name last_name - is_marreid + is_married capital_city num1 @@ -517,7 +577,7 @@ Valid variables in JavaScript: ``` camelCase or the first way of declaring is conventional in JavaScript. In this material, we will use camelCase variables. -Invalid variable: +Invalid variables: ```sh first-name @@ -528,7 +588,7 @@ Invalid variable: Let us declare variables with different data types. To declare a variable, we need to use let or const keyword before the variable name. Following the variable name, we write an equal sign (assignment operator), and a value. ```js - # Syntax + // Syntax let nameOfVariable = value ``` @@ -536,12 +596,12 @@ Let us declare variables with different data types. To declare a variable, we ne ```js // Declaring different variables of different data types - -let firstName = 'Asabeneh' // first name of a person -let lastName = 'Yetayeh' // last name of a person -let country = 'Finland' // country -let city = 'Helsinki' // capital city -let isMarried = true // boolean data type +let firstName = 'Asabeneh' // first name of a person +let lastName = 'Yetayeh' // last name of a person +let country = 'Finland' // country +let city = 'Helsinki' // capital city +let age = 100 // age in years +let isMarried = true console.log(firstName, lastName, country, city, age, isMarried) ``` @@ -580,13 +640,13 @@ When you run the files on 01-Day folder you should get this: ![Day one](./images/day_1.png) -🌕 You are amazing. You have just completed day 1 challenge and you are in your way to greatness. Now do some exercises for your brain and for your muscle. +🌕 You are amazing! You have just completed day 1 challenge and you are on your way to greatness. Now do some exercises for your brain and for your muscle. # 💻 Day 1: Exercises 1. Write a single line comment which says, _comments can make code readable_ -2. Write another single comment which says, *welcome to 30DaysOfJavaScript* -3. Write a multiline comment which says, _comments can make code readable, easy to use_ +2. Write another single comment which says, *Welcome to 30DaysOfJavaScript* +3. Write a multiline comment which says, _comments can make code readable, easy to reuse_ _and informative_ 4. Create a variable.js file and declare variables and assign string, boolean, undefined and null data types @@ -604,4 +664,4 @@ When you run the files on 01-Day folder you should get this: 🎉 CONGRATULATIONS ! 🎉 -[Day 2 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/02_Day/02_day_data_types.md) +[Day 2 >>](./02_Day_Data_types/02_day_data_types.md)