You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
236 lines
4.0 KiB
236 lines
4.0 KiB
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'
|
|
]
|
|
|
|
|
|
const isEthiopia = countries.includes('Ethopia');
|
|
|
|
if(isEthiopia){
|
|
console.log('Ethiopia');
|
|
} else {
|
|
countries.push('Ethiopia');
|
|
console.log(countries);
|
|
}
|
|
|
|
|
|
const firstTenCountries = countries.slice(0, 10);
|
|
console.log(firstTenCountries);
|
|
//['Afghanistan', 'Albania', 'Algeria', 'Andorra', 'Angola', 'Antigua and Barbuda', 'Argentina', 'Armenia', 'Australia', 'Austria']
|
|
|
|
const middleIndex = Math.floor(countries.length / 2);
|
|
|
|
if (countries.length % 2 === 1) {
|
|
// If the array has an odd number of countries
|
|
const middleCountry = countries[middleIndex];
|
|
console.log('Middle Country (Odd):', middleCountry);
|
|
} else {
|
|
// If the array has an even number of countries
|
|
const middleCountry1 = countries[middleIndex - 1];
|
|
const middleCountry2 = countries[middleIndex];
|
|
console.log('Middle Countries (Even):', middleCountry1, middleCountry2);
|
|
}
|
|
|
|
let firstHalf;
|
|
let secondHalf;
|
|
|
|
if(countries.length % 2 === 0) {
|
|
firstHalf = countries.slice(0, middleIndex);
|
|
secondHalf = countries.slice(middleIndex);
|
|
} else {
|
|
firstHalf = countries.slice(0, middleIndex+1);
|
|
secondHalf = countries.slice(middleIndex + 1);
|
|
}
|
|
console.log('First Half:', firstHalf);
|
|
console.log('Second Half:', secondHalf); |