Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Branch name #420

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
56cc092
test folder created
Fitsumhelina Nov 21, 2024
9d53e56
exercice one - array
Fitsumhelina Nov 21, 2024
81b694c
50% solved
Fitsumhelina Nov 21, 2024
2dc864d
70% solved
Fitsumhelina Nov 21, 2024
beb04fa
80% solved
Fitsumhelina Nov 21, 2024
5deea33
90% solved
Fitsumhelina Nov 21, 2024
b8eb627
100% solved
Fitsumhelina Nov 21, 2024
5737857
folder changed
Fitsumhelina Nov 21, 2024
2612372
exersice two added
Fitsumhelina Nov 21, 2024
9028b4c
object-exercise-1 added and 100% solved
Fitsumhelina Nov 21, 2024
2c65f62
object-exercise-2 10% complated and folder update
Fitsumhelina Nov 21, 2024
86707f7
20% complated
Fitsumhelina Nov 21, 2024
4927cef
object-exercise-2 100% complated
Fitsumhelina Nov 21, 2024
d9e83d5
40% complated
Fitsumhelina Nov 21, 2024
3993cb5
50% complated
Fitsumhelina Nov 21, 2024
e154454
90% compalted
Fitsumhelina Nov 21, 2024
38653a5
100% complated
Fitsumhelina Nov 21, 2024
61a4ba8
100% complated
Fitsumhelina Nov 21, 2024
0551d2c
10% complated
Fitsumhelina Nov 21, 2024
4982ad8
40% complated
Fitsumhelina Nov 21, 2024
6fd93ad
second option added
Fitsumhelina Nov 21, 2024
21e73f5
30% compalted
Fitsumhelina Nov 22, 2024
7eb4cd5
30% compalted
Fitsumhelina Nov 22, 2024
721ad7c
product rating 100% complated
Fitsumhelina Nov 22, 2024
ecbb533
product rating 100% complated
Fitsumhelina Nov 22, 2024
11e5194
likeproduct 100%compalted
Fitsumhelina Nov 22, 2024
656beaa
function exresice 1 90% complated
Fitsumhelina Nov 22, 2024
d9cc6e0
100% compalted
Fitsumhelina Nov 22, 2024
350fcf6
replece() method 100%
Fitsumhelina Nov 23, 2024
040f1bc
replece() method 100%
Fitsumhelina Nov 23, 2024
f18a476
some change
Fitsumhelina Nov 28, 2024
9207ca6
fuction exercise one 100% commplated
Fitsumhelina Nov 28, 2024
888772e
test file addded
Fitsumhelina Nov 28, 2024
0b59f7a
some change
Fitsumhelina Nov 28, 2024
4c7d6a6
user rate product count update
Fitsumhelina Nov 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions Exercises/day-1/array-exersise-1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// 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()
console.log(itCompanies)
// Print the number of companies in the array
console.log(itCompanies.length)
// Print the first company, middle and last company
console.log(itCompanies[0], itCompanies[Math.floor(itCompanies.length / 2)], itCompanies[itCompanies.length - 1])
// Print out each company
itCompanies.forEach(company => console.log(company))
// Change each company name to uppercase one by one and print them out
itCompanies.forEach(company => console.log(company.toUpperCase()))
// Print the array like as a sentence: Facebook, Google, Microsoft, Apple, IBM,Oracle and Amazon are big IT companies.
console.log(itCompanies.join(', ') + ' 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
const company = 'Google'
if (itCompanies.includes(company)) {
console.log(company +'is found in the array.')
} else {
console.log(company +'is not found in the array.')
}
// Filter out companies which have more than one 'o' without the filter method
const filteredCompanies = itCompanies.filter(company => company.toLowerCase().indexOf('o') === -1)
console.log(filteredCompanies)
// Sort the array using sort() method
console.log(itCompanies.sort())
// Reverse the array using reverse() method
console.log(itCompanies.reverse())
// Slice out the first 3 companies from the array
console.log(itCompanies.slice(0, 3))
// Slice out the last 3 companies from the array
console.log(itCompanies.slice(-3))
// Slice out the middle IT company or companies from the array
console.log(itCompanies.slice(3, 4))
// Remove the first IT company from the array
console.log(itCompanies.shift())
// Remove the middle IT company or companies from the array
console.log(itCompanies.splice(3, 1))
// Remove the last IT company from the array
console.log(itCompanies.pop())
// Remove all IT companies
console.log(itCompanies.splice(0))
28 changes: 28 additions & 0 deletions Exercises/day-1/array-exersise-2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Exercise: Level 2
// Create a separate countries.js file and store the countries array into this file, create a separate file web_techs.js and store the webTechs array into this file. Access both file in main.js file


// First remove all the punctuations and change the string to array and count the number of words in the array

let text ='I love teaching and empowering people. I teach HTML, CSS, JS, React, Python.'
const word = text.replace(/[,.]/gi ,'').split(' ')
console.log(word)
// In the following shopping cart add, remove, edit items

const shoppingCart = ['Milk', 'Coffee', 'Tea', 'Honey']
// add 'Meat' in the beginning of your shopping cart if it has not been already added
// add Sugar at the end of you shopping cart if it has not been already added
// remove 'Honey' if you are allergic to honey
// modify Tea to 'Green Tea'

// In countries array check if 'Ethiopia' exists in the array if it exists print 'ETHIOPIA'. If it does not exist add to the countries list.

// In the webTechs array check if Sass exists in the array and if it exists print 'Sass is a CSS preprocess'. If it does not exist add Sass to the array and print the array.

// Concatenate the following two variables and store it in a fullStack variable.

const frontEnd = ['HTML', 'CSS', 'JS', 'React', 'Redux']
const backEnd = ['Node', 'Express', 'MongoDB']

console.log(fullStack)
["HTML", "CSS", "JS", "React", "Redux", "Node", "Express", "MongoDB"]
34 changes: 34 additions & 0 deletions Exercises/day-1/function-exercise-1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Create a function called getPersonInfo. The getPersonInfo function takes an object parameter.
// The structure of the object and the output of the function is given below. Try to use both a regular way and destructuring
// and compare the cleanness of the code. If you want to compare your solution with my solution, check this link.

const person = {
firstName: 'Asabeneh',
lastName: 'Yetayeh',
age: 250,
country: 'Finland',
job: 'Instructor and Developer',
skills: [
'HTML',
'CSS',
'JavaScript',
'React',
'Redux',
'Node',
'MongoDB',
'Python',
'D3.js',
],
languages: ['Amharic', 'English', 'Suomi(Finnish)'],
}

const getPersonInfo = (person) => {
const {firstName, lastName, age, country, job, skills, languages} = person;
const {skill1,skill2,skill3,skill4,skill5,skill6,skill7,skill8,skill9} = skills;
console.log(`${firstName} ${lastName} lives in ${country}. He is ${age} years old. He is an ${job}. He teaches ${skill1}, ${skill2}, ${skill3}, ${skill4}, ${skill5}, ${skill6}, ${skill7}, ${skill8}, ${skill9}. He speaks ${languages[0]}, ${languages[1]} and a little bit of ${languages[2]}`);
}

getPersonInfo(person)
/*
Asabeneh Yetayeh lives in Finland. He is 250 years old. He is an Instructor and Developer. He teaches HTML, CSS, JavaScript, React, Redux, Node, MongoDB, Python and D3.js. He speaks Amharic, English and a little bit of Suomi(Finnish)
*/
56 changes: 56 additions & 0 deletions Exercises/day-1/function-exersice-1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Exercises: Level 1

// Declare a function fullName and it takes firstName, lastName as a parameter and it returns your full - name.
const fullname = (firstname, lastname) => {
return `${firstname} ${lastname}`
}
// Declare a function addNumbers and it takes two two parameters and it returns sum.
const sum = (a, b) =>{
return a + b
}

// Area of a circle is calculated as follows: area = π x r x r. Write a function which calculates _areaOfCircle
const areaOfCircle = (r,pi=3.14) => {
return pi * r * r
}

// Temperature in oC can be converted to oF using this formula: oF = (oC x 9/5) + 32. Write a function which convert oC to oF convertCelciusToFahrenheit.
const temperature = (oC) => {
return (oC * 9/5) + 32
}

// Body mass index(BMI) is calculated as follows: bmi = weight in Kg / (height x height) in m2. Write a function which calculates bmi. BMI is used to broadly define different weight groups in adults 20 years old or older.Check if a person is underweight, normal, overweight or obese based the information given below.
const BMI = (W,H) => {
let bmi= W / (H * H)
if (bmi>18.4 || bmi<25){
return 'Normal weight'
}
else if (bmi>25){
return 'Overweight'
}
else{
return 'Underweight'
}
}
// The same groups apply to both men and women.

// Underweight: BMI is less than 18.5
// Normal weight: BMI is 18.5 to 24.9
// Overweight: BMI is 25 to 29.9
// Obese: BMI is 30 or more

// Write a function called checkSeason, it takes a month parameter and returns the season:Autumn, Winter, Spring or Summer.
const checkSeason = (month) => {
if (month >= 3 && month <= 5){
return 'Spring'
}
else if (month >= 6 && month <= 8){
return 'Summer'
}
else if (month >= 9 && month <= 11){
return 'Autumn'
}
else{
return 'Winter'
}
}
24 changes: 24 additions & 0 deletions Exercises/day-1/object-exercise-1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Exercises: Level 1

// Create an empty object called dog
const dog = {}
// Print the the dog object on the console
console.log(dog)
// Add name, legs, color, age and bark properties for the dog object. The bark property is a method which return woof woof
dog.name = 'Buddy'
dog.legs = 4
dog.color = 'Golden'
dog.age = 3
// Get name, legs, color, age and bark value from the dog object
console.log(dog.name) // Output: Buddy
console.log(dog.legs) // Output: 4
console.log(dog.color) // Output: Golden
console.log(dog.age) // Output: 3
console.log(dog.bark()) // Output: Woof woof
// Set new properties the dog object: breed, getDogInfo
dog.breed = 'Labrador'
dog.getDogInfo = function() {
return `Name: ${this.name}, Age: ${this.age}, Color: ${this.color}, Breed: ${this.breed}`
}
// Get the dogInfo from the dog object
console.log(dog.getDogInfo()) // Output: Name: Buddy, Age: 3, Color: Golden, Breed: Labrador
123 changes: 123 additions & 0 deletions Exercises/day-1/object-exercise-2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
const users = {
Alex: {
email: '[email protected]',
skills: ['HTML', 'CSS', 'JavaScript'],
age: 20,
isLoggedIn: false,
points: 30
},
Asab: {
email: '[email protected]',
skills: ['HTML', 'CSS', 'JavaScript', 'Redux', 'MongoDB', 'Express', 'React', 'Node'],
age: 25,
isLoggedIn: false,
points: 50
},
Brook: {
email: '[email protected]',
skills: ['HTML', 'CSS', 'JavaScript', 'React', 'Redux'],
age: 30,
isLoggedIn: true,
points: 50
},
Daniel: {
email: '[email protected]',
skills: ['HTML', 'CSS', 'JavaScript', 'Python'],
age: 20,
isLoggedIn: false,
points: 40
},
John: {
email: '[email protected]',
skills: ['HTML', 'CSS', 'JavaScript', 'React', 'Redux', 'Node.js'],
age: 20,
isLoggedIn: true,
points: 50
},
Thomas: {
email: '[email protected]',
skills: ['HTML', 'CSS', 'JavaScript', 'React'],
age: 20,
isLoggedIn: false,
points: 40
},
Paul: {
email: '[email protected]',
skills: ['HTML', 'CSS', 'JavaScript', 'MongoDB', 'Express', 'React', 'Node'],
age: 20,
isLoggedIn: false,
points: 40
}
}
// Find the person who has many skills in the users object.
let maxskill =0
let mostskilledperson=null
for (const user in users){
const skillcount = users[user].skills.length
if (skillcount > maxskill){
maxskill = skillcount
mostskilledperson = user
}
}
console.log(`The person with the most skills is ${mostskilledperson} with ${maxskill} skills.`)

// Count logged in users,count users having greater than equal to 50 points from the following object.
let looged = 0
let person = 0
for (const user in users ){
if (users[user].points >= 50 ){
person++

}
if (users[user].isLoggedIn){
looged++
}
}

console.log(`Number of logged in users are ${looged}. ${person} users are greater than 50`)

// Find people who are MERN stack developer from the users object
const mern = ["MongoDB", "Express", "React", "Node"];
let dev = 0;

for (const user in users) {
if (mern.every(skill => users[user].skills.includes(skill))) {
dev++;
}
}

console.log(`Number of MERN stack developers are ${dev}.`);

// Set your name in the users object without modifying the original users object
const copyperson = Object.assign({}, users)
copyperson.Fitsum = {
name: "Fitsum",
skills: ["HTML", "CSS", "JavaScript", "React"],
points: 95,
isLoggedIn: true,
};

// console.log(copyperson.Fitsum);
const key = Object.keys(copyperson)
console.log(`Key ${key}`)


// Get all the values of users object
const val = Object.values(copyperson)
console.log(`Value ${val}`)

// Use the countries object to print a country name, capital, populations and languages.
const country = {
name: "Japan",
capital: "Tokyo",
population: 126476461,
languages: ["Japanese"],
}
const getinfo = function (copyperson ) {
console.log(`Country Name: ${copyperson.name}`)
console.log(`Capital: ${copyperson.capital}`)
console.log(`Population: ${copyperson.population}`)
console.log(`Languages: ${copyperson.languages.join(", ")}`)
}

getinfo(country)
Loading