Merge d4cbe51d64
into 29e4101818
commit
66e2f5ae9d
@ -1 +1,94 @@
|
||||
// this is your main.js script
|
||||
// this is your main.js script
|
||||
let challenge = "30 Days Of Javascript";
|
||||
// console.log(challenge);
|
||||
// console.log(challenge.length);
|
||||
// console.log(challenge.toUpperCase());
|
||||
// console.log(challenge.toLowerCase());
|
||||
// console.log(challenge.substring(0, 2));
|
||||
// console.log(challenge.substring(3));
|
||||
// console.log(challenge.includes("Script"));
|
||||
// console.log(challenge.split());
|
||||
// console.log(challenge.split(" "));
|
||||
// console.log('Facebook, Google, Microsoft, Apple, IBM, Oracle, Amazon'.split(","));
|
||||
// console.log(challenge.replace("Javascript", "Python"));
|
||||
// console.log(challenge.charAt(15));
|
||||
// console.log(challenge.charCodeAt("J"));
|
||||
// console.log(challenge.indexOf("a"));
|
||||
// console.log(challenge.lastIndexOf("a"));
|
||||
// console.log(
|
||||
// "You cannot end a sentence with because because because is a conjunction".indexOf("because")
|
||||
// );
|
||||
// console.log(
|
||||
// "You cannot end a sentence with because because because is a conjunction".lastIndexOf(
|
||||
// "because"
|
||||
// )
|
||||
// );
|
||||
// console.log(
|
||||
// "You cannot end a sentence with because because because is a conjunction".search(
|
||||
// "because"
|
||||
// )
|
||||
// );
|
||||
// console.log(" 30 Days Of Javascript ".trim(" "));
|
||||
// console.log(challenge.startsWith("30"));
|
||||
// console.log(challenge.endsWith("Javascript"));
|
||||
// console.log(challenge.match(/a/gi));
|
||||
// let challenge2 = "30 Days of";
|
||||
// let challenge3 = "Javascript";
|
||||
// console.log(challenge2.concat(" ", challenge3))
|
||||
// console.log(challenge.repeat(3))
|
||||
|
||||
// console.log(`The quote 'There is no exercise better for the heart than reaching down and lifing people up.' by John Holmes teaches us to help one another.`)
|
||||
|
||||
// console.log(`"Love is not patronizing and charity isn't about pity, it is about love. Charity and love are the same -- with charity you give love, so don't just give money but reach out your hand instead."
|
||||
// `);
|
||||
// console.log(parseFloat("10") === 10);
|
||||
// console.log("python".includes("on") && "jargon".includes("on"))
|
||||
// // console.log("I hope this course is not full of jargon".includes("jargon"))
|
||||
// console.log(`1\t1\t1\t1\t1\n2\t1\t2\t4\t8\n3\t1\t3\t9\t27\n4\t1\t4\t16\t64\n5\t1\t5\t25\t125`);
|
||||
// console.log(Math.floor(Math.random() * (100 - 50) + 50));
|
||||
// console.log(Math.floor(Math.random() * 256));
|
||||
// console.log("Javascript".charAt(Math.floor(Math.random() * "Javascript".length)));
|
||||
let text =
|
||||
"You cannot end a sentence with because because because in a conjunction";
|
||||
// console.log(text.substring(text.indexOf("because"), text.lastIndexOf("because")));
|
||||
// console.log(text.lastIndexOf("because"));
|
||||
let text2 = text.split(" ");
|
||||
text2.splice(text2.indexOf("because"), 3);
|
||||
console.log(text2.join(" "));
|
||||
|
||||
let loveText =
|
||||
"Love is the best thing in this world. Some found their love and some are still looking for their love";
|
||||
|
||||
let counter = 0;
|
||||
loveText.split(" ").forEach((element) => {
|
||||
element.toLowerCase() === "love" ? counter++ : undefined;
|
||||
});
|
||||
console.log(counter);
|
||||
console.log(text.match(/because/gi).length);
|
||||
let income =
|
||||
"He earns 5000 euro from salary per month, 10000 euro annual bonus, 15000 euro online courses per month.";
|
||||
let incomechunks = income.split(",");
|
||||
let totalIncome = 0;
|
||||
incomechunks.forEach((chunk) => {
|
||||
if (chunk.includes("month")) {
|
||||
chunk
|
||||
.trim()
|
||||
.split(" ")
|
||||
.forEach((chunksalary) => {
|
||||
if (+chunksalary > 0) {
|
||||
totalIncome += chunksalary * 12;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (chunk.includes("annual")) {
|
||||
chunk
|
||||
.trim()
|
||||
.split(" ")
|
||||
.forEach((chunksalary) => {
|
||||
if (+chunksalary > 0) {
|
||||
totalIncome += +chunksalary;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
console.log(totalIncome);
|
||||
|
@ -1 +1,101 @@
|
||||
// this is your main.js script
|
||||
// this is your main.js script
|
||||
// let firstname = "Frank";
|
||||
// let lastName = "Willis";
|
||||
// let country = "Kenya";
|
||||
// let city = "Mombasa";
|
||||
// let age = 28;
|
||||
// let isMarried = true;
|
||||
// let year = new Date().getFullYear();
|
||||
// let year2 = 2025;
|
||||
|
||||
console.log(4 > 3); //true
|
||||
console.log(4 >= 3); //true
|
||||
console.log(4 < 3); //false
|
||||
console.log(4 <= 3); //false
|
||||
console.log(4 == 4); //true
|
||||
console.log(4 === 4); //true
|
||||
console.log(4 != 4); //false
|
||||
console.log(4 !== 4); //false
|
||||
console.log(4 != "4"); //false
|
||||
console.log(4 == "4"); //true
|
||||
console.log(4 === "4"); //false
|
||||
|
||||
console.log("python".length != "jargon".length)
|
||||
|
||||
console.log(4 > 3 && 10 < 12); //true
|
||||
console.log(4 > 3 && 10 > 12); //false
|
||||
console.log(4 > 3 || 10 < 12); //true
|
||||
console.log(4 > 3 || 10 > 12); //true
|
||||
console.log(!(4 > 3)); //false
|
||||
console.log(!(4 < 3)); //true
|
||||
console.log(!false); //true
|
||||
console.log(!(4 > 3 && 10 < 12)); //false
|
||||
console.log(!(4 > 3 && 10 > 12)); //true
|
||||
console.log(!(4 === "4")); //true
|
||||
|
||||
let base = window.prompt("Enter the base");
|
||||
let height = window.prompt("Enter the height");
|
||||
let area = base * height * 0.5;
|
||||
window.alert(`The area is ${area}`);
|
||||
|
||||
let sidea = window.prompt("Enter the first side");
|
||||
let sideb = window.prompt("Enter the second side");
|
||||
let sidec = window.prompt("Enter the third side");
|
||||
let perimeter = Number(sidea) + Number(sideb) + Number(sidec);
|
||||
window.alert(`The perimeer of the triangle is ${perimeter}`);
|
||||
|
||||
let hours = window.prompt("Enter hours worked");
|
||||
let rateperhour = window.prompt("Enter rate per hour");
|
||||
let totalpay = hours * rateperhour;
|
||||
window.alert(`Your pay is $ ${totalpay}`);
|
||||
|
||||
console.log("FrankWillis".length > 7 ? "My name is long" : "My name is short");
|
||||
let firstName = "Frank";
|
||||
let lastName = "Anais";
|
||||
|
||||
firstName.length > lastName.length
|
||||
? console.log(
|
||||
`Your first name, ${firstName} is longer than your family name, ${lastName}`
|
||||
)
|
||||
: console.log(
|
||||
`Your first name, ${lastName} is longer than your family name, ${firstName}`
|
||||
);
|
||||
|
||||
let myAge = 25;
|
||||
let yourAge = 252;
|
||||
|
||||
myAge > yourAge
|
||||
? console.log(`I am ${myAge - yourAge} years older than you.`)
|
||||
: console.log(`You are ${yourAge - myAge} years older than me.`);
|
||||
|
||||
let yearOfBirth = window.prompt("Enter year of birth");
|
||||
let currentYear = new Date().getFullYear();
|
||||
let currentAge = currentYear - yearOfBirth;
|
||||
currentAge >= 18
|
||||
? window.alert(`You are ${currentAge}. You are old enough to drive`)
|
||||
: window.alert(
|
||||
`You are ${currentAge}. You will be allowed to drive after ${
|
||||
18 - currentAge
|
||||
}`
|
||||
);
|
||||
|
||||
let noYears = window.prompt("Enter years to be converted");
|
||||
let seconds = noYears * 365 * 24 * 3600;
|
||||
window.alert(`You lived ${seconds} seconds`);
|
||||
|
||||
let now = new Date();
|
||||
let year = now.getFullYear();
|
||||
let month = now.getMonth();
|
||||
let date = now.getDate();
|
||||
let hour = now.getHours();
|
||||
let minutes = now.getMinutes();
|
||||
|
||||
minutes > 9 ? minutes : minutes = `0${minutes}`;
|
||||
hour > 9 ? hour : (hour = `0${hour}`);
|
||||
month > 9 ? month++ : month = `0${month + 1}`;
|
||||
|
||||
// console.log(`${year}-0${month+1}-${date} ${hour}:${minutes}`)
|
||||
// console.log(`${date}-0${month+1}-${year} ${hour}:${minutes}`);
|
||||
// console.log(`${date}/0${month + 1}/${year} ${hour}:${minutes}`);
|
||||
|
||||
console.log(`${year}-${month}-${date} ${hour}:${minutes}`);
|
||||
|
@ -1,3 +1,122 @@
|
||||
// this is your main.js script
|
||||
|
||||
alert('Open the browser console whenever you work on JavaScript')
|
||||
// alert('Open the browser console whenever you work on JavaScript')
|
||||
|
||||
// let age = window.prompt("Enter your age");
|
||||
// let message =
|
||||
// age >= 18
|
||||
// ? `You are old enough to drive`
|
||||
// : `You are left with ${18 - age} years to drive`;
|
||||
// window.alert(message);
|
||||
|
||||
// let myAge = 82;
|
||||
// let yourAge = 32;
|
||||
|
||||
// let comparison =
|
||||
// myAge > yourAge
|
||||
// ? `I am ${myAge - yourAge} years older than you`
|
||||
// : `You are ${yourAge - myAge} years older than me`;
|
||||
// console.log(comparison);
|
||||
|
||||
// let a = 21;
|
||||
// let b = 22;
|
||||
// const greater =
|
||||
// a > b
|
||||
// ? `${a} is greater than ${b}`
|
||||
// : b > a
|
||||
// ? `${b} is greater than ${a}`
|
||||
// : `${a} is equal to ${b}`;
|
||||
// console.log(greater);
|
||||
|
||||
// let number = 10;
|
||||
// const result = number % 2 == 0 ? `${number} is an even number` : `${number} is an odd number`;
|
||||
// console.log(result)
|
||||
|
||||
// let score = window.prompt("Enter the score");
|
||||
// switch (true) {
|
||||
// case score >= 80 && score <= 100:
|
||||
// console.log("A");
|
||||
// break;
|
||||
// case score >= 70 && score < 80:
|
||||
// console.log("B");
|
||||
// break;
|
||||
// case score >= 60 && score < 70:
|
||||
// console.log("C");
|
||||
// break;
|
||||
// case score >= 50 && score < 60:
|
||||
// console.log("D");
|
||||
// break;
|
||||
// default:
|
||||
// console.log("F");
|
||||
// break;
|
||||
// }
|
||||
|
||||
// let period = window
|
||||
// .prompt("Enter the month to find out the season")
|
||||
// .toLowerCase();
|
||||
|
||||
// switch (true) {
|
||||
// case period == "september" || period == "october" || period == "november":
|
||||
// console.log("The season is Autumn");
|
||||
// break;
|
||||
// case period == "december" || period == "january" || period == "february":
|
||||
// console.log("The season is Winter");
|
||||
// break;
|
||||
// case period == "march" || period == "april" || period == "may":
|
||||
// console.log("The season is Spring");
|
||||
// break;
|
||||
// default:
|
||||
// console.log("The season is Summer");
|
||||
// }
|
||||
|
||||
// let day = "friday".toLowerCase();
|
||||
|
||||
// switch (true) {
|
||||
// case day == "saturday" || day == "sunday":
|
||||
// let processedWeekend = day.split("");
|
||||
// processedWeekend.splice(0, 1);
|
||||
// console.log(
|
||||
// `${day.charAt(0).toUpperCase()}${processedWeekend.join(
|
||||
// ""
|
||||
// )} is a weekend`
|
||||
// );
|
||||
// break;
|
||||
// default:
|
||||
// let processedWeekDay = day.split("");
|
||||
// processedWeekDay.splice(0, 1);
|
||||
// console.log(
|
||||
// `${day.charAt(0).toUpperCase()}${processedWeekDay.join(
|
||||
// ""
|
||||
// )} is a weekday`
|
||||
// );
|
||||
|
||||
// }
|
||||
|
||||
let months = [
|
||||
"January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December",
|
||||
];
|
||||
|
||||
let daysNormal = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
||||
let daysLeap = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
||||
|
||||
let month = "March";
|
||||
|
||||
let currYear = new Date().getFullYear();
|
||||
let isLeap = currYear % 4 == 0 ? "leap" : "normal";
|
||||
|
||||
console.log(
|
||||
isLeap == "leap"
|
||||
? `The number of days in ${month} are ${daysLeap[months.indexOf(month)]}`
|
||||
: `The number of days in ${month} are ${daysNormal[months.indexOf(month)]}`
|
||||
);
|
||||
|
@ -0,0 +1,9 @@
|
||||
export const webTechs = [
|
||||
"HTML",
|
||||
"CSS",
|
||||
"JavaScript",
|
||||
"React",
|
||||
"Redux",
|
||||
"Node",
|
||||
"MongoDB",
|
||||
];
|
@ -1,3 +0,0 @@
|
||||
console.log(countries)
|
||||
alert('Open the browser console whenever you work on JavaScript')
|
||||
alert('Open the console and check if the countries has been loaded')
|
@ -0,0 +1,252 @@
|
||||
// import { webTechs } from "../data/webtechs";
|
||||
import { countries } from "../data/countries.mjs";
|
||||
import { webTechs } from "../data/webtechs.mjs";
|
||||
|
||||
//Declare an empty array;
|
||||
const emptyArray = [];
|
||||
|
||||
//Declare an array with more than 5 number of elements
|
||||
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
|
||||
//Find the length of the array
|
||||
// console.log("Length of numbers array:", numbers.length);
|
||||
|
||||
//Get the first, middle and last elements of the array
|
||||
// console.log("First Item:", numbers[0]);
|
||||
// console.log("Middle Item:", numbers[Math.floor(numbers.length / 2)]);
|
||||
// console.log("Last Item:", numbers[numbers.length - 1]);
|
||||
|
||||
//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
|
||||
const mixedDataTypes = [
|
||||
1,
|
||||
"string",
|
||||
true,
|
||||
null,
|
||||
undefined,
|
||||
{ key: "value" },
|
||||
[1, 2, 3],
|
||||
];
|
||||
|
||||
//Declare an array variable name it itCompanies and assign initial values
|
||||
const itCompanies = [
|
||||
"Facebook",
|
||||
"Google",
|
||||
"Microsoft",
|
||||
"Apple",
|
||||
"IBM",
|
||||
"Oracle",
|
||||
"Amazon",
|
||||
"Netflix",
|
||||
];
|
||||
|
||||
//Print the array using console.log()
|
||||
// console.log("IT Companies:", itCompanies);
|
||||
|
||||
//Print the number of companies in the array
|
||||
// console.log("IT Companies count:", itCompanies.length);
|
||||
|
||||
//Print the first, middle and last IT company
|
||||
// console.log("First IT Company:", itCompanies[0]);
|
||||
// console.log(
|
||||
// "Middle IT Company:",
|
||||
// itCompanies[Math.floor(itCompanies.length / 2)]
|
||||
// );
|
||||
// console.log("Last IT Company:", itCompanies[itCompanies.length - 1]);
|
||||
|
||||
//Print out each company
|
||||
// console.log("IT Companies List:");
|
||||
// itCompanies.forEach((company) => console.log(company));
|
||||
|
||||
//Change each company name to uppercase one by one and print them out
|
||||
// console.log("Companies in Uppercase");
|
||||
// itCompanies.forEach((company) => console.log(company.toUpperCase()));
|
||||
|
||||
//Print out the Array as a sentence
|
||||
// console.log(itCompanies.toString());
|
||||
|
||||
//Check if a certain company exists in the itCompanies array. If it exists, return the company else return a company is not found
|
||||
let companySearch = "IBAM";
|
||||
// itCompanies.includes(companySearch) == true
|
||||
// ? console.log(companySearch, "has been found")
|
||||
// : console.log(`The company ${companySearch} is not found`);
|
||||
|
||||
//Filter out companies which have more than one "o" without the filter method
|
||||
// console.log("Companies with double o")
|
||||
let doubleo = [];
|
||||
for (let company of itCompanies) {
|
||||
company.match(/oo/gm) ? doubleo.push(company) : null;
|
||||
}
|
||||
// console.log(doubleo);
|
||||
|
||||
//Sort the array using sort() method
|
||||
// console.log(itCompanies.sort());
|
||||
|
||||
//Reverse the array using the reverse() method
|
||||
// console.log(itCompanies.reverse());
|
||||
|
||||
//Slice out the first 3 companies from the array
|
||||
// itCompanies.splice(0, 3);
|
||||
// console.log(itCompanies)
|
||||
|
||||
//Slice out the last 3 companies from the array
|
||||
// itCompanies.splice(itCompanies.length - 3, 3);
|
||||
// console.log(itCompanies)
|
||||
|
||||
//Slice out the middle IT company or companies from the array
|
||||
// if (itCompanies.length % 2 > 0) {
|
||||
// itCompanies.splice(Math.floor(itCompanies.length / 2), 1);
|
||||
// } else {
|
||||
// itCompanies.splice(Math.floor(itCompanies.length / 2) - 1, 2);
|
||||
// }
|
||||
// console.log(itCompanies)
|
||||
|
||||
//Remove the first IT company from the array
|
||||
// itCompanies.shift();
|
||||
// console.log(itCompanies)
|
||||
|
||||
//Remove the middle IT company or companies from the array
|
||||
// if (itCompanies.length % 2 > 0) {
|
||||
// itCompanies.splice(Math.floor(itCompanies.length / 2), 1);
|
||||
// } else {
|
||||
// itCompanies.splice(Math.floor(itCompanies.length / 2) - 1, 2);
|
||||
// }
|
||||
// console.log(itCompanies)
|
||||
|
||||
//Remove the last IT company from the array
|
||||
// itCompanies.pop();
|
||||
// console.log(itCompanies);
|
||||
|
||||
//Remove all the IT companies
|
||||
// console.log(itCompanies.splice());
|
||||
|
||||
//LEVEL 2
|
||||
|
||||
//Create separate files for countries and web_techs and access from this file.
|
||||
// console.log(countries)
|
||||
// console.log(webTechs);
|
||||
|
||||
//Remove punctuations and change the string to array and count the number of words in it.
|
||||
|
||||
let text =
|
||||
"I love teaching and empowering people. I teach HTML, CSS, JS, React, Python.";
|
||||
|
||||
let words = text.replace(/\,|\./gm, "").split(" ");
|
||||
// console.log("Text Array:", words)
|
||||
// console.log(`Text Length: ${words.length}`);
|
||||
|
||||
//In the following shopping cart add, remove, edit items
|
||||
const shoppingCart = ["Milk", "Coffee", "Tea", "Honey"];
|
||||
|
||||
//Add 'Meat' in the beginning of your shoppinh cart if it has not been already added
|
||||
let foodToAdd = "Meat";
|
||||
let checkFood = shoppingCart.includes(foodToAdd);
|
||||
!checkFood ? shoppingCart.unshift(foodToAdd) : "";
|
||||
// console.log(shoppingCart);
|
||||
|
||||
//Add Sugar at the end of your shopping cart if it has not already been added
|
||||
let foodToAdd2 = "Sugar";
|
||||
let checkFood2 = shoppingCart.includes(foodToAdd2);
|
||||
!checkFood2 ? shoppingCart.push(foodToAdd2) : "";
|
||||
// console.log(shoppingCart);
|
||||
|
||||
//Remove Honey if you are allergic to honey
|
||||
let foodToRemove = "Honey";
|
||||
let allergy = shoppingCart.includes(foodToRemove);
|
||||
allergy ? shoppingCart.splice(shoppingCart.indexOf(foodToRemove), 1) : null;
|
||||
// console.log(shoppingCart);
|
||||
|
||||
//Modify Tea to 'Green Tea'
|
||||
let searchItem = "Tea";
|
||||
let checkItem = shoppingCart.includes(searchItem);
|
||||
checkItem
|
||||
? (shoppingCart[shoppingCart.indexOf(searchItem)] = "Green Tea")
|
||||
: null;
|
||||
// console.log(shoppingCart);
|
||||
|
||||
//Check if Ethiopia exists in the countries array. If it exists, print 'ETHIOPIA'. If not, add it to the countries list
|
||||
let checkCountries = countries.includes("Ethiopia");
|
||||
checkCountries ? console.log("ETHIOPIA") : countries.push("Ethiopia");
|
||||
|
||||
//Check if Sass exists in webTechs, if it exists, print 'Sass is a CSS Preprocessor'. If not, add Sass to webTechs
|
||||
|
||||
let checkWebTechs = webTechs.includes("Sass");
|
||||
checkWebTechs
|
||||
? console.log("Sass is a CSS Preprocessor")
|
||||
: webTechs.push("Sass");
|
||||
// console.log(webTechs);
|
||||
|
||||
//Concatenate the following two variables and store it in a fullStack variable
|
||||
const frontEnd = ["HTML", "CSS", "JS", "React", "Redux"];
|
||||
const backend = ["Node", "Express", "MongoDB"];
|
||||
|
||||
let fullStack = frontEnd.concat(backend);
|
||||
// console.log(fullStack);
|
||||
|
||||
//LEVEL 3
|
||||
|
||||
//sort array of student ages
|
||||
const ages = [19, 22, 19, 24, 20, 25, 26, 24, 25, 24];
|
||||
|
||||
ages.sort((a, b) => a - b);
|
||||
|
||||
console.log(ages);
|
||||
|
||||
//Find the median age (one middle item or two middle items divided by two)
|
||||
let median =
|
||||
ages.length % 2 > 0
|
||||
? ages[Math.floor(ages.length / 2)]
|
||||
: Math.round((ages[ages.length / 2 - 1] + ages[ages.length / 2]) / 2);
|
||||
// console.log(median)
|
||||
|
||||
//Find the average age (all items divided by number of items)
|
||||
let sumAges = 0;
|
||||
ages.forEach((age) => (sumAges += age));
|
||||
let average = sumAges / ages.length;
|
||||
// console.log(average);
|
||||
|
||||
//Find the range of the ages (max minus min)
|
||||
let minAge = Math.min(...ages);
|
||||
let maxAge = Math.max(...ages);
|
||||
//using arrays after sorting
|
||||
//let minAge = ages[0]
|
||||
//let maxAge = ages.reverse()[0];
|
||||
let range = maxAge - minAge;
|
||||
// console.log(range)
|
||||
|
||||
//Compare the value of (min - average) and (max - average), use abs() method
|
||||
let minval = minAge - average;
|
||||
let maxval = maxAge - average;
|
||||
console.log(Math.abs(maxval - minval));
|
||||
|
||||
//Slice the first ten countries from countries array
|
||||
// console.log(countries.slice(0, 10));
|
||||
|
||||
//Find the middle country(ies) in the countries array
|
||||
countries.length % 2 !== 0
|
||||
? console.log(countries[Math.ceil(countries.length / 2) - 1])
|
||||
: console.log(
|
||||
countries[Math.floor(countries.length / 2 - 2)],
|
||||
countries[Math.floor(countries.length / 2 - 1)]
|
||||
);
|
||||
|
||||
//Divide the countries array into two equal arrays if it is even. if not, add one more country to the first half
|
||||
|
||||
let firstHalf = [];
|
||||
let secondHalf = [];
|
||||
|
||||
let isEven = countries.length % 2 !== 0 ? false : true;
|
||||
|
||||
isEven
|
||||
? (firstHalf.push(...countries.slice(0, countries.length / 2)),
|
||||
secondHalf.push(...countries.slice(countries.length / 2, countries.length)))
|
||||
: (firstHalf.push(...countries.slice(0, Math.ceil(countries.length / 2))),
|
||||
secondHalf.push(
|
||||
...countries.slice(Math.ceil(countries.length / 2), countries.length)
|
||||
));
|
||||
|
||||
console.log(isEven);
|
||||
console.log(countries.length);
|
||||
console.log(firstHalf.length, firstHalf);
|
||||
console.log(secondHalf.length, secondHalf);
|
||||
|
||||
console.log("New change");
|
@ -1,2 +1,3 @@
|
||||
console.log(countries)
|
||||
alert('Open the console and check if the countries has been loaded')
|
||||
alert('Open the console and check if the countries has been loaded')
|
||||
console.log("loops")
|
Loading…
Reference in new issue