parent
56cc092ac9
commit
9d53e5695a
@ -0,0 +1,54 @@
|
|||||||
|
// Exercise: Level 1
|
||||||
|
|
||||||
|
const countries = [
|
||||||
|
'Albania',
|
||||||
|
'Bolivia',
|
||||||
|
'Canada',
|
||||||
|
'Denmark',
|
||||||
|
'Ethiopia',
|
||||||
|
'Finland',
|
||||||
|
'Germany',
|
||||||
|
'Hungary',
|
||||||
|
'Ireland',
|
||||||
|
'Japan',
|
||||||
|
'Kenya',
|
||||||
|
]
|
||||||
|
|
||||||
|
const webTechs = [
|
||||||
|
'HTML',
|
||||||
|
'CSS',
|
||||||
|
'JavaScript',
|
||||||
|
'React',
|
||||||
|
'Redux',
|
||||||
|
'Node',
|
||||||
|
'MongoDB',
|
||||||
|
]
|
||||||
|
// 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]
|
||||||
|
// Find the length of your array
|
||||||
|
console.log(numbers.length)
|
||||||
|
// Get the first item, the middle item and the last item of the array
|
||||||
|
console.log(numbers[0], numbers[Math.floor(numbers.length / 2)], 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, 'two', true, { name: 'John' }, [1, 2, 3, 4, 5]]
|
||||||
|
// Declare an array variable name itCompanies and assign initial values Facebook, Google, Microsoft, Apple, IBM, Oracle and Amazon
|
||||||
|
const itCompanies = ['Facebook', 'Google', 'Microsoft', 'Apple', 'IBM', 'Oracle', 'Amazon']
|
||||||
|
// Print the array using console.log()
|
||||||
|
// Print the number of companies in the array
|
||||||
|
// Print the first company, middle and last company
|
||||||
|
// Print out each company
|
||||||
|
// Change each company name to uppercase one by one and print them out
|
||||||
|
// Print the array like as a sentence: Facebook, Google, Microsoft, Apple, IBM,Oracle and Amazon are big IT companies.
|
||||||
|
// Check if a certain company exists in the itCompanies array. If it exist return the company else return a company is not found
|
||||||
|
// Filter out companies which have more than one 'o' without the filter method
|
||||||
|
// Sort the array using sort() method
|
||||||
|
// Reverse the array using reverse() method
|
||||||
|
// Slice out the first 3 companies from the array
|
||||||
|
// Slice out the last 3 companies from the array
|
||||||
|
// Slice out the middle IT company or companies from the array
|
||||||
|
// Remove the first IT company from the array
|
||||||
|
// Remove the middle IT company or companies from the array
|
||||||
|
// Remove the last IT company from the array
|
||||||
|
// Remove all IT companies
|
Loading…
Reference in new issue