diff --git a/.DS_Store b/.DS_Store index d06ffd2ea..3ec22e315 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Week2/homwork/Grade.js b/Week2/homwork/Grade.js new file mode 100644 index 000000000..aa56005d0 --- /dev/null +++ b/Week2/homwork/Grade.js @@ -0,0 +1,28 @@ +function calculateGrade(grade){ + let g = '' + switch(true){ + case (grade >= 90): + g='A'; + break; + case (grade >= 80): + g='B'; + break; + case (grade >=70): + g='C'; + break; + case (grade >=60): + g='D'; + break; + case (grade >=50): + g='E'; + break; + case (grade <50): + g='F'; + break; + + } + return 'you got ' +g+ " (" +grade+ '%)!' + +} + +console.log(calculateGrade(89)); \ No newline at end of file diff --git a/Week2/homwork/ex1.js b/Week2/homwork/ex1.js new file mode 100644 index 000000000..607c688fe --- /dev/null +++ b/Week2/homwork/ex1.js @@ -0,0 +1,4 @@ +let myString = "hello,this,is,a,difficult,to,read,sentence"; +console.log(myString.length) +myString = myString.replace(/,/g," "); +console.log(myString); diff --git a/Week2/homwork/ex2.js b/Week2/homwork/ex2.js new file mode 100644 index 000000000..0c5eff901 --- /dev/null +++ b/Week2/homwork/ex2.js @@ -0,0 +1,5 @@ +for ( let i = 0; i <= 20; i++) { if ( i % 2 == 0) + console.log(i,'is even'); + else + console.log( i,'is ood' ) +} \ No newline at end of file diff --git a/Week2/homwork/ex3.js b/Week2/homwork/ex3.js new file mode 100644 index 000000000..00cb06119 --- /dev/null +++ b/Week2/homwork/ex3.js @@ -0,0 +1,7 @@ +let MealRecipe = { MealName : "Hummus", Serves : 2, +Ingredients:[ '200g chickpeas','2 tbsp lemon juice' ,'2 garlic cloves, crushed', ] +} ; +console.log(MealRecipe); +for (food in MealRecipe) { + console.log(food +' : '+ MealRecipe[food]) +} \ No newline at end of file diff --git a/Week2/homwork/ex4.js b/Week2/homwork/ex4.js new file mode 100644 index 000000000..cc82d328f --- /dev/null +++ b/Week2/homwork/ex4.js @@ -0,0 +1,28 @@ +var books = [ + {title: 'the stranger ', author: 'albert camus' , alreadyRead: true }, + {title: 'the idiot', author: 'dostoevsky' , alreadyRead: false }, + {title: 'The Alchemist', author: 'Paulo Coelho' , alreadyRead: true } + +]; + +for(let i = 0; i < books.length; i++){ + console.log(books[i]);} + +console.log('') + +books.forEach (function(obj) { + console.log(obj.title + " by " +obj.author ) +}); +console.log('') + +for (book of books) +{ + if (book.alreadyRead===true){ console.log( 'You still need to read ' +book.title ) + } + else { console.log ( 'You already read ' + book.title) + + } +} + + + diff --git a/Week2/homwork/ex5.js b/Week2/homwork/ex5.js new file mode 100644 index 000000000..7438a76fe --- /dev/null +++ b/Week2/homwork/ex5.js @@ -0,0 +1,23 @@ +let drinkTray =[] +const drinkTypes = ["cola", "lemonade", "water"]; +for (var i = 0; i < 5; i++){ + if (i<=1){ + drinkTray.push(drinkTypes[0]) + } + if (i>=2 && i<=3){ + drinkTray.push(drinkTypes[1]) + } + if (i>=4){ + drinkTray.push(drinkTypes[2]) + } +} + +console.log(drinkTray) +console.log('') + +let hey = 'Hey guys, I brought a ' +for(drink of drinkTray){ + hey = hey + drink+' ,' +} +console.log(hey); + diff --git a/Week3/homowrk/ex1.js b/Week3/homowrk/ex1.js new file mode 100644 index 000000000..83c1343bb --- /dev/null +++ b/Week3/homowrk/ex1.js @@ -0,0 +1,15 @@ +function random(min, max) { + return Math.floor(Math.random() * (max - min + 1)) + min; + } +function giveCompliment(name){ + let compliment =[ 'awesome','smart','impeccable','perfect','great','courageous' + ,'strong','wonderful','fabulous','astonishing']; + + let s1 = "you are "+compliment[random(0,9 )]+" "+name + console.log(s1) + return s1 + } +giveCompliment("karam") +giveCompliment("karam") +giveCompliment("karam") + diff --git a/Week3/homowrk/ex2.js b/Week3/homowrk/ex2.js new file mode 100644 index 000000000..f4ca68507 --- /dev/null +++ b/Week3/homowrk/ex2.js @@ -0,0 +1,7 @@ +function calculateDogAge(number){ +let dogAge= number*7; +console.log("Your doggie is "+dogAge+" years old in dog years!") +} +calculateDogAge(3); +calculateDogAge(9); +calculateDogAge(11); \ No newline at end of file diff --git a/Week3/homowrk/ex3.js b/Week3/homowrk/ex3.js new file mode 100644 index 000000000..695b97786 --- /dev/null +++ b/Week3/homowrk/ex3.js @@ -0,0 +1,34 @@ + +const numChildren = [1, 2, 3, 4, 5]; +const partnerNames = ['charlotte','Emma','Sophie','layla','luna']; +const locations = ['Brussels', 'luxembourg', 'Rotterdam', 'Amsterdam', 'Madrid']; +const jobs = ['Artist', 'Ploiceman', 'Doctor', 'Lawyer', 'farmer']; + +function random( partnerNames) +{ +return partnerNames[Math.floor(Math.random()*partnerNames.length)]; +} + +function random(locations) +{ +return locations[Math.floor(Math.random()*locations.length)]; + +} + +function random(jobs) +{ +return jobs[Math.floor(Math.random()*jobs.length)]; + +} + +function random(numChildren) +{ +return numChildren[Math.floor(Math.random()*jobs.length)]; + +} +function tellFortune(numChild, partner, location, job) { + return `You will be a ${random(jobs)} in ${random(locations)}, + and married to ${random(partnerNames)} with ${random(numChildren)} kids.` +} +console.log(tellFortune(numChildren, partnerNames, locations, jobs)) + diff --git a/Week3/homowrk/ex4.js b/Week3/homowrk/ex4.js new file mode 100644 index 000000000..8b5944a5c --- /dev/null +++ b/Week3/homowrk/ex4.js @@ -0,0 +1,15 @@ +let groceryList = ['bananas', 'milk']; + + +function addToShoppingCart(Item) { + groceryList.push(Item); + if(groceryList.length>3){ + groceryList.shift(groceryList); + + } + return `You bought `+groceryList+" !"; +} + +console.log(addToShoppingCart("onion")); +console.log(addToShoppingCart("cheese")); +console.log(addToShoppingCart("parsley")); \ No newline at end of file diff --git a/Week3/homowrk/ex5.js b/Week3/homowrk/ex5.js new file mode 100644 index 000000000..98bc7a005 --- /dev/null +++ b/Week3/homowrk/ex5.js @@ -0,0 +1,14 @@ + +let cartForParty = { + beers:1.30, chips:2.20 , cake:0.99 , nuts:3.40 ,cola:2.25 +} + +function calculateTotalPrice(expenses){ + let all=0; + for (expense of Object.values(expenses)){ + all=all+expense + } +return all; +} + +console.log(calculateTotalPrice(cartForParty)) \ No newline at end of file diff --git a/Week3/homowrk/project.js b/Week3/homowrk/project.js new file mode 100644 index 000000000..73a53eed9 --- /dev/null +++ b/Week3/homowrk/project.js @@ -0,0 +1,42 @@ +function validateCard(cardNumber){ + + if( isNaN(cardNumber)) + { + console.log("invalid characters"); + return; + } + + let sameNumbers = true; + for(let i =0;i