parent
3527139fb1
commit
11fda60bb9
@ -0,0 +1,13 @@
|
|||||||
|
module.exports = countries = [
|
||||||
|
'Albania',
|
||||||
|
'Bolivia',
|
||||||
|
'Canada',
|
||||||
|
'Denmark',
|
||||||
|
'Ethiopia',
|
||||||
|
'Finland',
|
||||||
|
'Germany',
|
||||||
|
'Hungary',
|
||||||
|
'Ireland',
|
||||||
|
'Japan',
|
||||||
|
'Kenya',
|
||||||
|
]
|
@ -0,0 +1,49 @@
|
|||||||
|
const countries = require('./countries')
|
||||||
|
const webTechs = require("./web_techs")
|
||||||
|
|
||||||
|
console.log(countries)
|
||||||
|
console.log(webTechs)
|
||||||
|
|
||||||
|
|
||||||
|
let text = 'I love teaching and empowering people. I teach HTML, CSS, JS, React, Python.'
|
||||||
|
let words = text.replace('/[,]+/g', ' ').split(' ')
|
||||||
|
|
||||||
|
console.log(words)
|
||||||
|
console.log(words.length)
|
||||||
|
|
||||||
|
|
||||||
|
const shoppingCart = ['Milk', 'Coffee', 'Tea', 'Honey']
|
||||||
|
|
||||||
|
shoppingCart.includes('Meat') ? '' : shoppingCart.push('Meat')
|
||||||
|
shoppingCart.includes('Sugar') ? '' : shoppingCart.push('Sugar')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
let alergic = true
|
||||||
|
if (alergic) {
|
||||||
|
let index = shoppingCart.indexOf('Honey')
|
||||||
|
shoppingCart.splice(index, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (countries.includes('Ethiopia')) {
|
||||||
|
let index = countries.indexOf('Ethiopia')
|
||||||
|
console.log(countries[index].toUpperCase())
|
||||||
|
} else {
|
||||||
|
countries.push('Ethiopia')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (webTechs.includes('Sass')) {
|
||||||
|
console.log('Sass is a CSS preprocess')
|
||||||
|
} else {
|
||||||
|
webTechs.push('Sass')
|
||||||
|
console.log(webTechs)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const frontEnd = ['HTML', 'CSS', 'JS', 'React', 'Redux']
|
||||||
|
const backEnd = ['Node', 'Express', 'MongoDB']
|
||||||
|
|
||||||
|
const fullStack = [...frontEnd, ...backEnd]
|
||||||
|
console.log(fullStack)
|
@ -0,0 +1,9 @@
|
|||||||
|
module.exports = webTechs = [
|
||||||
|
'HTML',
|
||||||
|
'CSS',
|
||||||
|
'JavaScript',
|
||||||
|
'React',
|
||||||
|
'Redux',
|
||||||
|
'Node',
|
||||||
|
'MongoDB',
|
||||||
|
]
|
@ -0,0 +1,195 @@
|
|||||||
|
module.exports = 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'
|
||||||
|
]
|
@ -0,0 +1,48 @@
|
|||||||
|
// 1. The following is an array of 10 students ages: js const
|
||||||
|
// ages = [19, 22, 19, 24, 20, 25, 26, 24, 25, 24]
|
||||||
|
// - Sort the array and find the min and 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
|
||||||
|
|
||||||
|
const age = [19, 22, 19, 24, 20, 25, 26, 24, 25, 24]
|
||||||
|
|
||||||
|
let min = Math.min(...age)
|
||||||
|
let max = Math.max(...age)
|
||||||
|
|
||||||
|
age.sort()
|
||||||
|
let [m1, m2] = [(age.length / 2), (age.length / 2 + 1)]
|
||||||
|
let median = (age[m1] + age[m2]) / 2
|
||||||
|
|
||||||
|
let average = age.reduce((x, y) => {
|
||||||
|
return x + y
|
||||||
|
}, 0) / age.length
|
||||||
|
|
||||||
|
let range = max - min
|
||||||
|
|
||||||
|
|
||||||
|
// 1. Slice the first ten countries from the countries array
|
||||||
|
const countries = require('./countries')
|
||||||
|
|
||||||
|
let firstTen = countries.slice(0, 9)
|
||||||
|
|
||||||
|
// 2. Find the middle country(ies) in the countries array
|
||||||
|
let middle = Math.floor(countries.length / 2)
|
||||||
|
|
||||||
|
|
||||||
|
// 3. 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.
|
||||||
|
let arr1, arr2 = []
|
||||||
|
|
||||||
|
if (countries.length % 2 == 0) {
|
||||||
|
let middle = (countries.length / 2)
|
||||||
|
|
||||||
|
arr1 = countries.slice(0, middle)
|
||||||
|
arr2 = countries.slice(middle, countries.length)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let middle = Math.ceil(countries.length / 2)
|
||||||
|
|
||||||
|
arr1 = countries.slice(0, middle)
|
||||||
|
arr2 = countries.slice(middle, countries.length)
|
||||||
|
}
|
Loading…
Reference in new issue