parent
a1dc4bdeef
commit
d62975106e
@ -0,0 +1,56 @@
|
||||
let example1 = Array();
|
||||
let example2 = Array(6);
|
||||
console.log(example2.length);
|
||||
console.log(
|
||||
example2[0],
|
||||
example2[example2.length - 1],
|
||||
example2[Math.trunc(example2.length / 2)]
|
||||
);
|
||||
let mixedDataTypes = [0, 1.3, "test", [0, 1], { test: "1" }];
|
||||
let itCompanies = [
|
||||
"Facebook",
|
||||
"Google",
|
||||
"Microsoft",
|
||||
"Apple",
|
||||
"IBM",
|
||||
"Oracle",
|
||||
"Amazon",
|
||||
];
|
||||
console.log(itCompanies);
|
||||
console.log(itCompanies.length);
|
||||
console.log(
|
||||
itCompanies[0],
|
||||
itCompanies[example2.length - 1],
|
||||
itCompanies[Math.trunc(itCompanies.length / 2)]
|
||||
);
|
||||
itCompanies.forEach((e) => {
|
||||
console.log(e);
|
||||
});
|
||||
itCompanies.forEach((e) => {
|
||||
console.log(e.toUpperCase());
|
||||
});
|
||||
console.log(itCompanies.join(", "), " are bit IT companies");
|
||||
itCompanies.includes("Google")
|
||||
? console.log("Google")
|
||||
: console.log("Company not found.");
|
||||
let filteredItCompanies = [];
|
||||
itCompanies.forEach((e) => {
|
||||
let counter = 0;
|
||||
for (i = 0; i < e.length; i++) {
|
||||
if (e[i] == "o") {
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
if (counter >= 2) {
|
||||
filteredItCompanies.push(e);
|
||||
}
|
||||
});
|
||||
console.log(itCompanies.sort());
|
||||
console.log(itCompanies.reverse());
|
||||
console.log(itCompanies.slice(0, 3));
|
||||
console.log(itCompanies.slice(3));
|
||||
console.log(itCompanies.slice(3, 1));
|
||||
console.log(itCompanies.splice(0, 3));
|
||||
console.log(itCompanies.splice(3, 3));
|
||||
console.log(itCompanies.splice(3, 1));
|
||||
console.log(itCompanies.splice(0));
|
@ -0,0 +1,13 @@
|
||||
const ages = [19, 22, 19, 24, 20, 25, 26, 24, 25, 24];
|
||||
|
||||
ages.sort();
|
||||
const min = ages[0];
|
||||
const max = ages[ages.length - 1];
|
||||
|
||||
let sum = 0;
|
||||
for (i = 0; i < ages.length; i++) {
|
||||
sum += ages[i];
|
||||
}
|
||||
const average = sum / ages.length;
|
||||
const median = ages[Math.trunc(ages.length / 2)];
|
||||
const range = max - min;
|
@ -0,0 +1,13 @@
|
||||
const countries = [
|
||||
"Albania",
|
||||
"Bolivia",
|
||||
"Canada",
|
||||
"Denmark",
|
||||
"Ethiopia",
|
||||
"Finland",
|
||||
"Germany",
|
||||
"Hungary",
|
||||
"Ireland",
|
||||
"Japan",
|
||||
"Kenya",
|
||||
];
|
@ -0,0 +1,32 @@
|
||||
import { countries } from "countries.js";
|
||||
import { webTech } from "web_tech.js";
|
||||
|
||||
let text =
|
||||
"I love teaching and empowering people. I teach HTML, CSS, JS, React, Python.";
|
||||
console.split(" ,.");
|
||||
console.log(words);
|
||||
console.log(words.length);
|
||||
|
||||
const shoppingCart = ["Milk", "Coffee", "Tea", "Honey"];
|
||||
shoppingCart.includes("Meat") ? () => {} : shoppingCart.unshift("Meat");
|
||||
shoppingCart.includes("Sugar") ? () => {} : shoppingCart.push("Sugar");
|
||||
shoppingCard.splice(2, 1, "Green Tea");
|
||||
|
||||
const country = countries.indexOf("Ethiopia");
|
||||
if (country > 0) {
|
||||
console.log(countries[country].toUpperCase());
|
||||
} else {
|
||||
countries.push("Ethiopia");
|
||||
}
|
||||
|
||||
const frontEnd = ["HTML", "CSS", "JS", "React", "Redux"];
|
||||
const backEnd = ["Node", "Express", "MongoDB"];
|
||||
|
||||
const fullStack = frontend.concat(backend);
|
||||
|
||||
console.log(fullStack);
|
||||
|
||||
console.log(countries.slice(0, 10));
|
||||
console.log(countries[Math.trunc(countries.length / 2)]);
|
||||
|
||||
const fhCountries = countries.splice(0, Math.round(countries.length / 2));
|
@ -0,0 +1,9 @@
|
||||
const webTechs = [
|
||||
"HTML",
|
||||
"CSS",
|
||||
"JavaScript",
|
||||
"React",
|
||||
"Redux",
|
||||
"Node",
|
||||
"MongoDB",
|
||||
];
|
Loading…
Reference in new issue