diff --git a/.gitignore b/.gitignore index 723ef36f4..bc6017416 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ -.idea \ No newline at end of file +.idea +master +.Dstore +.vscode/lunch.jason + diff --git a/Week1/homework/Masoud/js-exercises/EX1-helloWorld.js b/Week1/homework/Masoud/js-exercises/EX1-helloWorld.js new file mode 100644 index 000000000..75266831d --- /dev/null +++ b/Week1/homework/Masoud/js-exercises/EX1-helloWorld.js @@ -0,0 +1,12 @@ +'use strict'; + +console.log("Hello world!"); +console.log("دنیا سلام!"); +console.log("مرحبا بالعالم!"); +console.log("Привет мир!"); +console.log("Olá Mundo!"); +console.log("こんにちは世界!"); +console.log("silav dinya!"); +console.log("Ahoj světe!"); +console.log("สวัสดีชาวโลก!"); +console.log("Γειά σου Κόσμε!"); diff --git a/Week1/homework/Masoud/js-exercises/EX10-compareArrays.js b/Week1/homework/Masoud/js-exercises/EX10-compareArrays.js new file mode 100644 index 000000000..d50375ced --- /dev/null +++ b/Week1/homework/Masoud/js-exercises/EX10-compareArrays.js @@ -0,0 +1,12 @@ +'use strict'; + +let animal = ["birds", "monkeys", "cats", "dogs"]; +let oddNum = [1, 3, 5, 7, 9, 11, 13]; +console.log("The length of the array is " + oddNum.length); +console.log("The length of the array is " + animal.length); + +if(animal.length == oddNum.length) { + console.log("They are the same!"); +} else { + console.log("Two different size"); +} \ No newline at end of file diff --git a/Week1/homework/Masoud/js-exercises/EX2-errorDebugging.js b/Week1/homework/Masoud/js-exercises/EX2-errorDebugging.js new file mode 100644 index 000000000..8b554d6e4 --- /dev/null +++ b/Week1/homework/Masoud/js-exercises/EX2-errorDebugging.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log("I'm awesome!"); \ No newline at end of file diff --git a/Week1/homework/Masoud/js-exercises/EX3-logTheNumber.js b/Week1/homework/Masoud/js-exercises/EX3-logTheNumber.js new file mode 100644 index 000000000..df69ddd6f --- /dev/null +++ b/Week1/homework/Masoud/js-exercises/EX3-logTheNumber.js @@ -0,0 +1,11 @@ +'use strict'; + +let numberX; + +console.log("X is a integer number and equal to "); +console.log(numberX); + +numberX = 13; + +console.log("X is a integer number and equal to "); +console.log(numberX); \ No newline at end of file diff --git a/Week1/homework/Masoud/js-exercises/EX4-logTheString.js b/Week1/homework/Masoud/js-exercises/EX4-logTheString.js new file mode 100644 index 000000000..398821007 --- /dev/null +++ b/Week1/homework/Masoud/js-exercises/EX4-logTheString.js @@ -0,0 +1,9 @@ +'use strict'; + +let myString = "Masoud S"; +console.log("This is my full name:"); +console.log(myString); + +console.log("This is my changed full name:"); +myString = "Ali Haji"; +console.log(myString); \ No newline at end of file diff --git a/Week1/homework/Masoud/js-exercises/EX5-roundAAumberAndLogIt.js b/Week1/homework/Masoud/js-exercises/EX5-roundAAumberAndLogIt.js new file mode 100644 index 000000000..59f10abe5 --- /dev/null +++ b/Week1/homework/Masoud/js-exercises/EX5-roundAAumberAndLogIt.js @@ -0,0 +1,17 @@ +'use strict'; + +let z = 7.25; +console.log(z); + +let a = Math.round(z); +console.log(a); + +let greater; + +if (a >= z) { + greater = a; +} else { + greater = z; +} + +console.log(greater); \ No newline at end of file diff --git a/Week1/homework/Masoud/js-exercises/EX6-logAnArrayOfAnimals.js b/Week1/homework/Masoud/js-exercises/EX6-logAnArrayOfAnimals.js new file mode 100644 index 000000000..549cb6c48 --- /dev/null +++ b/Week1/homework/Masoud/js-exercises/EX6-logAnArrayOfAnimals.js @@ -0,0 +1,11 @@ +'use strict'; + +let items = []; +console.log("This in an array"); +console.log(items); + +let myFavAnimal = ["cats", "dogs", "rabbit"]; +console.log(myFavAnimal); + +myFavAnimal.push("Piglet"); +console.log(myFavAnimal); \ No newline at end of file diff --git a/Week1/homework/Masoud/js-exercises/EX7-logTheLengthOfAString.js b/Week1/homework/Masoud/js-exercises/EX7-logTheLengthOfAString.js new file mode 100644 index 000000000..023c2c403 --- /dev/null +++ b/Week1/homework/Masoud/js-exercises/EX7-logTheLengthOfAString.js @@ -0,0 +1,4 @@ +'use strict'; + +let mySentence = "Programming is so interesting"; +console.log(mySentence.length); \ No newline at end of file diff --git a/Week1/homework/Masoud/js-exercises/EX8-typeChecker.js b/Week1/homework/Masoud/js-exercises/EX8-typeChecker.js new file mode 100644 index 000000000..6dae9b081 --- /dev/null +++ b/Week1/homework/Masoud/js-exercises/EX8-typeChecker.js @@ -0,0 +1,40 @@ +'use strict'; + +function typeCheck(first, second) { + if(typeof first == typeof second) { + console.log("SAME TYPE"); + } else { + console.log("Not the same..."); + } +} + +let var1 = "I'm a string"; +let var2 = "I'm a string too"; + +let var3 = { + name: "Mas", + address: "Kerman" +}; + +let var4 = { + name: "Akbar", + address: "Tehran" +}; + +console.log(var1 + " & " + var2); +typeCheck(var1, var2); + +console.log(var1 + " & " + var3); +typeCheck(var1, var3); + +console.log(var1 + " & " + var4); +typeCheck(var1, var4); + +console.log(var2 + " & " + var3); +typeCheck(var2, var3); + +console.log(var2 + " & " + var4); +typeCheck(var2, var4); + +console.log(var3 + " & " + var4); +typeCheck(var3, var4); \ No newline at end of file diff --git a/Week1/homework/Masoud/js-exercises/EX9-logTheRemainder.js b/Week1/homework/Masoud/js-exercises/EX9-logTheRemainder.js new file mode 100644 index 000000000..8f17c3f2b --- /dev/null +++ b/Week1/homework/Masoud/js-exercises/EX9-logTheRemainder.js @@ -0,0 +1,10 @@ +'use strict'; + +let x = 7; +console.log(x % 3); //answer = 1 + +let y = 21; +console.log(y % 4); //answer = 1 + +let z = 13; +console.log(z % 2); //answer = 1 \ No newline at end of file diff --git a/Week1/homework/js-exercises/animals.js b/Week1/homework/js-exercises/animals.js new file mode 100644 index 000000000..3df445e99 --- /dev/null +++ b/Week1/homework/js-exercises/animals.js @@ -0,0 +1,7 @@ +let items = []; +console.log("This is an empty array"); +console.log(items); +let animals = ["Lion", "Tiger", "Monkey"]; +console.log(animals); +animals.push("Piglet"); +console.log(animals); diff --git a/Week1/homework/js-exercises/arrays.js b/Week1/homework/js-exercises/arrays.js new file mode 100644 index 000000000..29a83034d --- /dev/null +++ b/Week1/homework/js-exercises/arrays.js @@ -0,0 +1,11 @@ +let array1 = ["hello", 123, true, "hi"]; +let array2 = [23,54, "amir", "coding", 232,909, "love"]; +x = array1.length; +y = array2.length; +console.log('The lenghth of the array is ' + x); +console.log('The lenght of the array is ' + y); +if (x == y) { + console.log("They are the same!"); +} + +console.log("Two diffrent sizes"); \ No newline at end of file diff --git a/Week1/homework/js-exercises/awsome.js b/Week1/homework/js-exercises/awsome.js new file mode 100644 index 000000000..583b0a8be --- /dev/null +++ b/Week1/homework/js-exercises/awsome.js @@ -0,0 +1 @@ +console.log('I\'m awesome!'); \ No newline at end of file diff --git a/Week1/homework/js-exercises/checker.js b/Week1/homework/js-exercises/checker.js new file mode 100644 index 000000000..e18a4b8e5 --- /dev/null +++ b/Week1/homework/js-exercises/checker.js @@ -0,0 +1,45 @@ +let x1 = "string"; +let x2 = "string2"; +let x3 = 3 ; +let x4 = 4; +console.log(typeof(x1)); +console.log(typeof (x2)); +console.log(typeof(x3)); +console.log(typeof(x4)); +function compare () { + if (typeof(x1) == typeof(x2)) { + console.log("SAME TYPE"); + } else { + console.log("NOT THE SAME TYPE"); + }; + if (typeof(x1) == typeof(x3)) { + console.log("SAME TYPE"); + } else { + console.log("NOT THE SAME TYPE"); + }; + + if (typeof(x1) == typeof(x4)) { + console.log("SAME TYPE"); + } else { + console.log("NOT THE SAME TYPE"); + }; + + if (typeof(x2) == typeof(x3)) { + console.log("SAME TYPE"); + } else { + console.log("NOT THE SAME TYPE"); + }; + + if (typeof(x2) == typeof(x4)) { + console.log("SAME TYPE"); + } else { + console.log("NOT THE SAME TYPE"); + }; + + if (typeof(x3) == typeof(x4)) { + console.log("SAME TYPE"); + } else { + console.log("NOT THE SAME TYPE"); + }; +}; +compare(); \ No newline at end of file diff --git a/Week1/homework/js-exercises/length.js b/Week1/homework/js-exercises/length.js new file mode 100644 index 000000000..bfdcc880e --- /dev/null +++ b/Week1/homework/js-exercises/length.js @@ -0,0 +1,3 @@ +let mySentence = "Programming is so ineresting!"; +x = mySentence.length; +console.log(x); \ No newline at end of file diff --git a/Week1/homework/js-exercises/loghello.js b/Week1/homework/js-exercises/loghello.js new file mode 100644 index 000000000..5cd60eb38 --- /dev/null +++ b/Week1/homework/js-exercises/loghello.js @@ -0,0 +1,17 @@ + +console.log("Hello World"); +console.log("Hallo Welt"); +console.log("Talofa lalolagi"); +console.log("नमस्ते दुनिया"); +console.log("Halo Dunia"); +console.log("مرحبا بالعالم"); +console.log("سلام دنیا"); +console.log("Dia duit ar domhan"); +console.log("salve mundi"); +console.log("Selam Dünya"); + + + + + + diff --git a/Week1/homework/js-exercises/lognumber.js b/Week1/homework/js-exercises/lognumber.js new file mode 100644 index 000000000..eea9b5ff6 --- /dev/null +++ b/Week1/homework/js-exercises/lognumber.js @@ -0,0 +1,3 @@ +let numberX = 10; +console.log("I think the x is" +" "+ numberX) +console.log(numberX) \ No newline at end of file diff --git a/Week1/homework/js-exercises/reminder.js b/Week1/homework/js-exercises/reminder.js new file mode 100644 index 000000000..cf2ee21ce --- /dev/null +++ b/Week1/homework/js-exercises/reminder.js @@ -0,0 +1,12 @@ +let x = 7; +x = x % 3; +console.log(x) +//X would be 1; +let y = 21; +y = y % 4; +console.log(y) +// Y would be 1: +let z = 13; +z = z % 2; +console.log(z) +//Z would be 1. diff --git a/Week1/homework/js-exercises/roundnumber.js b/Week1/homework/js-exercises/roundnumber.js new file mode 100644 index 000000000..7ad9f7ef1 --- /dev/null +++ b/Week1/homework/js-exercises/roundnumber.js @@ -0,0 +1,10 @@ +var z = 7.25; +console.log(z); +let a = Math.round(z) +console.log(a); +if (a > z) { + let x = a +} +else; + let x = z +console.log(x) \ No newline at end of file diff --git a/Week1/homework/js-exercises/stringlog.js b/Week1/homework/js-exercises/stringlog.js new file mode 100644 index 000000000..b11ceddbc --- /dev/null +++ b/Week1/homework/js-exercises/stringlog.js @@ -0,0 +1,9 @@ +var myString = "Amir Hossein Shadravan" ; +console.log("The string is my full name"); +console.log(myString); +var myString = "Sarah Zamandi"; +console.log("I think Sarah's name will be shown"); +console.log(myString); + + + diff --git a/Week2/homework/Masoud/gradeCalculator/gradeCalculator.js b/Week2/homework/Masoud/gradeCalculator/gradeCalculator.js new file mode 100644 index 000000000..8cdb0b5d3 --- /dev/null +++ b/Week2/homework/Masoud/gradeCalculator/gradeCalculator.js @@ -0,0 +1,33 @@ +'use strict' +// creating function to change score or point to grade... +function gradeCalculator(point) { + let grade; + switch(true) { + case (point >= 0 && point < 49): + grade = 'F'; + break; + case (point >= 50 && point < 59): + grade = 'E'; + break; + case (point >= 60 && point < 69): + grade = 'D'; + break; + case (point >= 70 && point < 79): + grade = 'C'; + break; + case (point >= 80 && point < 89): + grade = 'B'; + break; + case (point >= 90 && point <= 100): + grade = 'A'; + break; + } +return `You got a ${grade} (${point}%)!` ; + +} + +//use function +let point = 60; +let grade = gradeCalculator(point); + +console.log(grade);//Show output in console \ No newline at end of file diff --git a/Week2/homework/Masoud/js-exercises/EX1-removeTheComma.js b/Week2/homework/Masoud/js-exercises/EX1-removeTheComma.js new file mode 100644 index 000000000..40f7fe20a --- /dev/null +++ b/Week2/homework/Masoud/js-exercises/EX1-removeTheComma.js @@ -0,0 +1,26 @@ +'use strict' + +let myString = 'hello,this,is,a,difficult,to,read,sentence'; + +console.log(myString.length); + +//----My way--> I like it +let changeStringToArray = []; +for (let i = 0 ; i < myString.length; i++){ + if (myString[i] == ','){ + changeStringToArray.push(" "); + } else { + changeStringToArray.push(myString[i]); + } +} + +let perfectSentence = ""; +for (let i = 0 ; i < changeStringToArray.length ; i++){ + perfectSentence += changeStringToArray[i]; +} + +console.log(perfectSentence); + + +//-----Searched in google-->easy way +console.log(myString.replace(/,/g, ' ')); \ No newline at end of file diff --git a/Week2/homework/Masoud/js-exercises/EX2-theEvenOddReporter.js b/Week2/homework/Masoud/js-exercises/EX2-theEvenOddReporter.js new file mode 100644 index 000000000..e44ef87d6 --- /dev/null +++ b/Week2/homework/Masoud/js-exercises/EX2-theEvenOddReporter.js @@ -0,0 +1,9 @@ +'use strict' + +for (let i = 0 ; i <=20 ; i++){ + if (i%2 == 0){ + console.log('The number ' + i +' is even'); + } else { + console.log('The number ' + i +' is odd'); + } +} \ No newline at end of file diff --git a/Week2/homework/Masoud/js-exercises/EX3-theRecipeCard.js b/Week2/homework/Masoud/js-exercises/EX3-theRecipeCard.js new file mode 100644 index 000000000..e2c03005f --- /dev/null +++ b/Week2/homework/Masoud/js-exercises/EX3-theRecipeCard.js @@ -0,0 +1,25 @@ +'use strict' + +let myMealRecipe = {}; +myMealRecipe = { + title : 'pizza', + servings : 2, + ingredients : ['cheese 1', 'flour 0.5', 'tomato 3', 'mozerrella 0.2'] +} + +// code with just for +let propertyCaption = ['Meal name', 'Serves', 'Ingredients']; +let myMealRecipeArray = Object.values(myMealRecipe); +let ingredientFinal = ""; + +for (let i = 0 ; i < propertyCaption.length ; i++) { + console.log(propertyCaption[i] + ": " + myMealRecipeArray[i]); +} + +// code with for in +let property ; +for (property in myMealRecipe){ + console.log(property + ': ' + myMealRecipe[property]); +} + + diff --git a/Week2/homework/Masoud/js-exercises/EX4-theReadingList.js b/Week2/homework/Masoud/js-exercises/EX4-theReadingList.js new file mode 100644 index 000000000..3adf65ad7 --- /dev/null +++ b/Week2/homework/Masoud/js-exercises/EX4-theReadingList.js @@ -0,0 +1,31 @@ +'use strict' + +let books = [ + { title : "ASTRONOMY FOR DUMMIES", + author : "STEPHEN P. MARAN", + alreadyRead : true + }, + + { title : "ASTRONOMY: A SELF-TEACHING GUIDE", + author : "DINAH L. MOCHE", + alreadyRead : false + }, + + { title : "THE UNIVERSE IN A NUTSHELL", + author : "STEPHEN HAWKING", + alreadyRead : true + } +]; + +for (let i =0 ; i < books.length ; i++) { + + console.log(books[i].title + ' by ' + books[i].author); + + if(books[i].alreadyRead) { + console.log('You already read \"' + books[i].title + '\"'); + } else { + console.log('You still need to read \"' + books[i].title + '\"'); + } + + console.log(''); +} \ No newline at end of file diff --git a/Week2/homework/Masoud/js-exercises/EX5-whoWantsADrink.js b/Week2/homework/Masoud/js-exercises/EX5-whoWantsADrink.js new file mode 100644 index 000000000..f6a0a4842 --- /dev/null +++ b/Week2/homework/Masoud/js-exercises/EX5-whoWantsADrink.js @@ -0,0 +1,24 @@ +'use strict' + +const drinkTray = []; +const drinkTypes = ['cola', 'lemonade', 'water']; +let num = 0; +let courser = 0; + +for(let i = 0 ; i < 5 ; i++) { + + drinkTray.push(drinkTypes[num]); + courser++; + + if(courser == 2){ + num++; + courser = 0; + } + + if (num == drinkTypes.length){ + num = 0; + } +} + +const finalSentence = drinkTray.join(', '); +console.log('Hey guys, I brought a ' + finalSentence + '!'); \ No newline at end of file diff --git a/Week2/homework/Masoud/tempConverter/app.js b/Week2/homework/Masoud/tempConverter/app.js new file mode 100644 index 000000000..e3f1dfd7c --- /dev/null +++ b/Week2/homework/Masoud/tempConverter/app.js @@ -0,0 +1,27 @@ +const celciusInput = document.querySelector('#celcius > input'); +const fahrenheitInput = document.querySelector('#fahrenheit > input'); +const kelvinInput = document.querySelector('#kelvin > input'); + +celciusInput.addEventListener('input', function() { + const cTemp = parseFloat(celciusInput.value); + const fTemp = (cTemp * (9/5)) + 32; + const kTemp = cTemp + 273; + fahrenheitInput.value = fTemp; + kelvinInput.value = kTemp; +}); + +fahrenheitInput.addEventListener('input', function() { + const fTemp = parseFloat(fahrenheitInput.value); + const cTemp = (5/9)*(fTemp - 32); + const kTemp = ((5/9)*(fTemp - 32)) + 273; + celciusInput.value = cTemp; + kelvinInput.value = kTemp; +}); + +kelvinInput.addEventListener('input', function() { + const kTemp = parseFloat(kelvinInput.value); + const cTemp = kTemp - 273; + const fTemp = ((kTemp - 273) * (9/5)) + 32; + celciusInput.value = cTemp; + fahrenheitInput.value = fTemp; +}); \ No newline at end of file diff --git a/Week2/homework/Masoud/tempConverter/favicon.ico b/Week2/homework/Masoud/tempConverter/favicon.ico new file mode 100644 index 000000000..29500f02b Binary files /dev/null and b/Week2/homework/Masoud/tempConverter/favicon.ico differ diff --git a/Week2/homework/Masoud/tempConverter/index.html b/Week2/homework/Masoud/tempConverter/index.html new file mode 100644 index 000000000..b46abf985 --- /dev/null +++ b/Week2/homework/Masoud/tempConverter/index.html @@ -0,0 +1,27 @@ + + + + + + Temperature Convertor + + + + +
+ +
+ +
+ +
+ +
+ +
+ + + + \ No newline at end of file diff --git a/Week2/homework/Masoud/tempConverter/style.css b/Week2/homework/Masoud/tempConverter/style.css new file mode 100644 index 000000000..ba5e56066 --- /dev/null +++ b/Week2/homework/Masoud/tempConverter/style.css @@ -0,0 +1,47 @@ +* { + padding: 0; + margin: 0; + box-sizing: border-box; +} + +body { + background-color: white; +} + +div { + height: 33.33vh; +} + +#fahrenheit { + border-bottom: 3px solid white; + border-top: 3px solid white; +} + +input[type='number'] { + width: 100%; + height: 100%; + background-color: black; + color: white; + font-size: 5em; + text-align: center; + border: 0; + outline: none; +} + +::-webkit-input-placeholder { + color: grey; +} + +::-moz-placeholder { + color: grey; +} + +::-ms-input-placeholder { + color: grey; +} + +input[type='number']::-webkit-inner-spin-button, +input[type='number']::-webkit-outer-spin-button { + -webkit-appearance: none; + margin: 0; +} diff --git a/Week2/homework/Masoud/weightConverter/index.html b/Week2/homework/Masoud/weightConverter/index.html new file mode 100644 index 000000000..14f8b38e7 --- /dev/null +++ b/Week2/homework/Masoud/weightConverter/index.html @@ -0,0 +1,68 @@ + + + + + + Weight Converter + + + + +
+
+
+

Weight Converter

+
+
+ +
+
+
+ +
+
+

grams:

+
+
+
+ +
+
+

Kilograms:

+
+
+
+ +
+
+

Ounces:

+
+
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/Week2/homework/js-exercises/drinks-ex5.js b/Week2/homework/js-exercises/drinks-ex5.js new file mode 100644 index 000000000..7e782541e --- /dev/null +++ b/Week2/homework/js-exercises/drinks-ex5.js @@ -0,0 +1,17 @@ +let drinkTray = []; +const drinkTypes = ['cola', 'lemonade', 'water']; +let pointer = 0; +let count = 0; +while (drinkTray.length < 5) { + drinkTray.push(drinkTypes[pointer]) + count++; + if (count ==2) { + pointer++; + count = 0; + }; + if (pointer >= drinkTypes.length) { + pointer = 0; + }; +}; +console.log(`Hey guys, I brought a ${drinkTray}!`); + diff --git a/Week2/homework/js-exercises/grade-calculator.js b/Week2/homework/js-exercises/grade-calculator.js new file mode 100644 index 000000000..1c4ffc6ed --- /dev/null +++ b/Week2/homework/js-exercises/grade-calculator.js @@ -0,0 +1,43 @@ +function calculategrades(gradeInput) { + let result = 0; + let gPercent = `${(gradeInput * 100) / 100}%`; //using this calculation to make the percentage of the grade. + switch (Math.floor(gradeInput/10)) { //Using Math.floor to round grades to largest integer and then read the reletive condition in the switch. + case 9: + result = "A"; + break; + case 8: + result = "B" + break; + case 7: + result = "C" + break; + case 6: + result = "D" + break; + case 5: + result = "E" + break; + case 4: + result = "F" + break; + case 3: + result = "F" + break; + case 2: + result = "F" + break; + case 1: + result = "F" + break; + case 0: + result = "F" + break; + } + return `You got a ${result} (${gPercent})!` +} +let x = calculategrades(60); +console.log(x); + + +// console.log(`${grades(1)}`) + diff --git a/Week2/homework/js-exercises/readinglist-ex4.js b/Week2/homework/js-exercises/readinglist-ex4.js new file mode 100644 index 000000000..06b631c1f --- /dev/null +++ b/Week2/homework/js-exercises/readinglist-ex4.js @@ -0,0 +1,35 @@ +'use strict' +let books = [ + { + title: "The Three Musketeers", + author: "Alexandre Dumas", + alreadyRead: true, + }, + { + title: "Harry Potter", + author: "J.K Rolling", + alreadyRead: false, + }, + { + title: "Deep Work", + author: "Kal Newport", + alreadyRead: false, + } +] + + + +books.forEach((element, index, array) => { + console.log(element.title + " by " + element.author); + if (element.alreadyRead) { + console.log("You already read " + element.title) + } else { + console.log("You still need to read " + element.title) + }; +}); + + + + + + diff --git a/Week2/homework/js-exercises/recipe-ex3.js b/Week2/homework/js-exercises/recipe-ex3.js new file mode 100644 index 000000000..52d5cb1a1 --- /dev/null +++ b/Week2/homework/js-exercises/recipe-ex3.js @@ -0,0 +1,27 @@ +"use strict" +let recipe = { + mealName : "Mirzaghasemi", + serves: 2, + ingredients : ["2 eggplants", "2 eggs", "1 garlic"] +}; +let x = ['Meal name', 'Serves', 'Ingredients'] +//Method1: +// for (let property in recipe) { +// console.log(property + ": " + recipe[property]); +// }; + +//Method2: +// for (let property in recipe) { +// console.log(`${property}: ${recipe[property]}`); +// }; + +//Method3: +let property = Object.keys(recipe); +let value = Object.values(recipe); + +for (let i = 0; i < Object.keys(recipe).length; i++) { + + console.log(x[i] + ": " + value[i]); + +}; + diff --git a/Week2/homework/js-exercises/removecComma-ex1.js b/Week2/homework/js-exercises/removecComma-ex1.js new file mode 100644 index 000000000..e6d546e89 --- /dev/null +++ b/Week2/homework/js-exercises/removecComma-ex1.js @@ -0,0 +1,5 @@ +'use strict'; +var myString = 'hello,this,is,a,difficult,to,read,sentence'; +console.log(myString.length); +var index = myString.replace(/,/g , " ") +console.log(index) diff --git a/Week2/homework/js-exercises/reporter-ex2.js b/Week2/homework/js-exercises/reporter-ex2.js new file mode 100644 index 000000000..541a8e3c2 --- /dev/null +++ b/Week2/homework/js-exercises/reporter-ex2.js @@ -0,0 +1,8 @@ +"use strict" +for (let i = 0; i < 20 ; i++) { + if (i % 2 == 0) { + console.log("The number " + i + " is even"); + } else { + console.log("The number " + i + " is odd") + } +}; \ No newline at end of file diff --git a/Week3/homework/Masoud/creditCardValidator/creditCardValidator.js b/Week3/homework/Masoud/creditCardValidator/creditCardValidator.js new file mode 100644 index 000000000..ad64b4e4e --- /dev/null +++ b/Week3/homework/Masoud/creditCardValidator/creditCardValidator.js @@ -0,0 +1,93 @@ +'use strict' + +const validateCreditNumber = (creditCardNumber) => { + + + //Input must be 16 characters + function checkLength(creditCardNumber) { + if (creditCardNumber.length !== 16){ + return false; + } else { + return true; + } + } + + //All characters must be numbers + function checkType(creditCardNumber) { + for (let i = 0 ; i < creditCardNumber.length ; i++) { + if (!creditCardNumber[i].match(/[0-9]/g)) { + return false; + } + } + return true; + } + + //At least two different numbers should be represented + function atLeastTwo(creditCardNumber) { + for (let i = 1 ; i < creditCardNumber.length ; i++) { + if (creditCardNumber[0] !== creditCardNumber[i]) { + return true; + } + } + return false; + } + + //The last number must be even + function mustEven(creditCardNumber) { + if (creditCardNumber[creditCardNumber.length-1] % 2 == 0) { + return true; + } else { + return false; + } + } + + //The sum of all the numbers must be greater than 16 + function sumOf(creditCardNumber){ + let sum = 0; + for (let i = 0 ; i < creditCardNumber.length ; i++){ + sum += parseInt(creditCardNumber[i]); + } + if (sum < 16) { + return false; + } else { + return true; + } + } + + + +//Call and console all Functions +const array = []; + +if (!checkLength(creditCardNumber)){ + array.push(`Invalid! The input ${creditCardNumber} should contains 16 characters!`); +} + +if (!checkType(creditCardNumber)){ + array.push(`Invalid! The input ${creditCardNumber} should contains only numbers!`); +} + +if (!atLeastTwo(creditCardNumber)){ + array.push(`Invalid! The input ${creditCardNumber} should contains at least 2 different types of numbers!`); +} + +if (!mustEven(creditCardNumber)){ + array.push(`Invalid! The last number must be even`); +} + +if (!sumOf(creditCardNumber)){ + array.push(`Invalid! The input ${creditCardNumber} should contains the numbers that must be greater than 16!`); +} + +if (array.length == 0){ + console.log(`Success! The input ${creditCardNumber} is a valid credit card number!`) +} else { + for (let i = 0 ; i < array.length ; i++) { + console.log(array[i]); + } +} +}; + +const creditCardNumber = '1111111111111112'; //Sample credit card number! +validateCreditNumber(creditCardNumber); //Call function + diff --git a/Week3/homework/Masoud/functionExercises/functionExercises.js b/Week3/homework/Masoud/functionExercises/functionExercises.js new file mode 100644 index 000000000..05b340ea6 --- /dev/null +++ b/Week3/homework/Masoud/functionExercises/functionExercises.js @@ -0,0 +1,35 @@ +//Ex1 +function noop() { +} +//----------------------------------------- + +//Ex2 +function longRondom() { + console.log(Math.random()); +} +longRondom(); +//----------------------------------------- + +//Ex3 +function getLength(string) { + return string.length; +} +const stringLength = getLength("I'm a perfect man"); +console.log(stringLength); + +//----------------------------------------- + +//Ex4 +function multiply(num1, num2) { + return num1 * num2; +} +const product = multiply(78, 13); +console.log(product); +//------------------------------------------ + +//Ex5 +function addFunctions(num1, num2, string) { + return multiply(num1, num2) + getLength(string); +} +const sum = addFunctions(12, 10, "I Love You"); +console.log(sum); \ No newline at end of file diff --git a/Week3/homework/Masoud/js-exercises/Ex1.js b/Week3/homework/Masoud/js-exercises/Ex1.js new file mode 100644 index 000000000..2ffc7c3bb --- /dev/null +++ b/Week3/homework/Masoud/js-exercises/Ex1.js @@ -0,0 +1,11 @@ +'use strict' + +function giveCompliment(name) { + const compliments = ['awesome', 'smart', 'perfect', 'strong', 'gratful', 'gorgeous', 'helpful', 'clever', 'handsome', 'great']; + const selectOneCompliment = compliments[Math.round(Math.random()*9)]; + return `You are ${selectOneCompliment}, ${name}!`; +} + +console.log(giveCompliment('Masoud')); +console.log(giveCompliment('Masoud')); +console.log(giveCompliment('Masoud')); \ No newline at end of file diff --git a/Week3/homework/Masoud/js-exercises/Ex2.js b/Week3/homework/Masoud/js-exercises/Ex2.js new file mode 100644 index 000000000..90ec3e7ef --- /dev/null +++ b/Week3/homework/Masoud/js-exercises/Ex2.js @@ -0,0 +1,10 @@ +'use strict' + +function calculateDogAge(age) { + const dogAge = age * 7; + return `your doggie is ${dogAge} years old in dog years!` +} + +console.log(calculateDogAge(3)); +console.log(calculateDogAge(5)); +console.log(calculateDogAge(8)); \ No newline at end of file diff --git a/Week3/homework/Masoud/js-exercises/Ex3.js b/Week3/homework/Masoud/js-exercises/Ex3.js new file mode 100644 index 000000000..f16aaff75 --- /dev/null +++ b/Week3/homework/Masoud/js-exercises/Ex3.js @@ -0,0 +1,20 @@ +'use strict' + +const numChildren = [1, 2, 3, 4, 5]; +const partnerNames = ['Olivia', 'Emma', 'Ava', 'Sophia', 'Isabella']; +const location = ['Iran', 'Netherland', 'poland', 'Italy', 'France']; +const job = ['teacher', 'doctor', 'engineer', 'builder', 'police']; + +function tellFortune() { + +const selectNumChilderen = numChildren[Math.round(Math.random()*4)]; +const selectPartnerNames = partnerNames[Math.round(Math.random()*4)]; +const selectLocation = location[Math.round(Math.random()*4)]; +const selectJob = job[Math.round(Math.random()*4)]; + +return `You will be a ${selectJob} in ${selectLocation}, married to ${selectPartnerNames} with ${selectNumChilderen} kids.` +} + +console.log(tellFortune()); +console.log(tellFortune()); +console.log(tellFortune()); \ No newline at end of file diff --git a/Week3/homework/Masoud/js-exercises/Ex4.js b/Week3/homework/Masoud/js-exercises/Ex4.js new file mode 100644 index 000000000..68d216492 --- /dev/null +++ b/Week3/homework/Masoud/js-exercises/Ex4.js @@ -0,0 +1,20 @@ +'use strict' + +const shoppingCard = ['banana', 'milk']; + +function addToShoppingCard(add) { + + if (shoppingCard.length <= 2){ + shoppingCard.push(add); + } else { + shoppingCard.shift(); + shoppingCard.push(add); + } + const shoppingCardString = shoppingCard.join(', '); + return `You bought ${shoppingCardString}!`; +} + +console.log(addToShoppingCard('bread')); +console.log(addToShoppingCard('tomato')); +console.log(addToShoppingCard('rice')); + diff --git a/Week3/homework/Masoud/js-exercises/Ex5.js b/Week3/homework/Masoud/js-exercises/Ex5.js new file mode 100644 index 000000000..170f04a63 --- /dev/null +++ b/Week3/homework/Masoud/js-exercises/Ex5.js @@ -0,0 +1,19 @@ +'use strict' + +const cardForParty = { + beers : 2.22, + bread : 1.8, + tea : 4, + cola : 8, + tomato : 3 +} + +function calculateTotalPrice(card) { + let totalPrice = 0; + for (let property in card){ + totalPrice += card[property]; + } + return `Total: \u20ac${totalPrice}`; +} + +console.log(calculateTotalPrice(cardForParty)); \ No newline at end of file diff --git a/Week3/homework/Masoud/meditationApp/app.js b/Week3/homework/Masoud/meditationApp/app.js new file mode 100644 index 000000000..d80e04397 --- /dev/null +++ b/Week3/homework/Masoud/meditationApp/app.js @@ -0,0 +1,92 @@ +const app = () => { +const song = document.querySelector(".song"); +const play = document.querySelector(".play"); +const replay = document.querySelector(".replay"); +const outline = document.querySelector(".moving-outline circle"); +const video = document.querySelector(".vid-container video"); +//Sounds +const sounds = document.querySelectorAll(".sound-picker button"); +//Time Display +const timeDisplay = document.querySelector(".time-display"); +const timeSelect = document.querySelectorAll('.time-select buttom'); +const outlineLength = outline.getTotalLength(); +//Duration +let fakeDuration = 600; + +outline.style.strokeDashoffset = outlineLength; +outline.style.strokeDasharray = outlineLength; + +play.addEventListener('click', () => { + checkPlaying(song); +}) + +const restartSong = song =>{ + let currentTime = song.currentTime; + song.currentTime = 0; + console.log("ciao") + +} +sounds.forEach(sound => { + sound.addEventListener("click", function() { + song.src = this.getAttribute("data-sound"); + video.src = this.getAttribute("data-video"); + checkPlaying(song); + }); +}); + +timeSelect.forEach(option => { + option.addEventListener("click", function() { + fakeDuration = this.getAttribute("data-time"); + timeDisplay.textContent = `${Math.floor(fakeDuration / 60)}:${Math.floor( + fakeDuration % 60 + )}`; + }); +}); + +const checkPlaying = song => { + if(song.paused){ + song.play(); + video.play(); + play.src = './svg/pause.svg' + } else { + song.pause(); + video.pause() + play.src = './svg/play.svg' + } +}; + + +song.ontimeupdate = () => { + let currentTime = song.currentTime; + let elapsed = fakeDuration - currentTime; + let seconds = Math.floor(elapsed % 60); + let minutes = Math.floor(elapsed / 60); + + + let progress = outlineLength - (currentTime / fakeDuration) * outlineLength; + outline.style.strokeDashoffset = progress + + timeDisplay.textContent = `${minutes}:${seconds}`; +} + +song.ontimeupdate = function() { + let currentTime = song.currentTime; + let elapsed = fakeDuration - currentTime; + let seconds = Math.floor(elapsed % 60); + let minutes = Math.floor(elapsed / 60); + timeDisplay.textContent = `${minutes}:${seconds}`; + let progress = outlineLength - (currentTime / fakeDuration) * outlineLength; + outline.style.strokeDashoffset = progress; + + if (currentTime >= fakeDuration) { + song.pause(); + song.currentTime = 0; + play.src = "./svg/play.svg"; + video.pause(); + } +}; + +}; + +app(); + diff --git a/Week3/homework/Masoud/meditationApp/index.html b/Week3/homework/Masoud/meditationApp/index.html new file mode 100644 index 000000000..8b16c3d33 --- /dev/null +++ b/Week3/homework/Masoud/meditationApp/index.html @@ -0,0 +1,46 @@ + + + + + + Meditation App + + + +
+
+ +
+ + + +
+ + + +
+
+ + play + + + + + + +

0:00

+ +
+
+ + +
+
+ + + + \ No newline at end of file diff --git a/Week3/homework/Masoud/meditationApp/sounds/beach.mp3 b/Week3/homework/Masoud/meditationApp/sounds/beach.mp3 new file mode 100644 index 000000000..dadf37e0e Binary files /dev/null and b/Week3/homework/Masoud/meditationApp/sounds/beach.mp3 differ diff --git a/Week3/homework/Masoud/meditationApp/sounds/rain.mp3 b/Week3/homework/Masoud/meditationApp/sounds/rain.mp3 new file mode 100644 index 000000000..e8425fcc6 Binary files /dev/null and b/Week3/homework/Masoud/meditationApp/sounds/rain.mp3 differ diff --git a/Week3/homework/Masoud/meditationApp/style.css b/Week3/homework/Masoud/meditationApp/style.css new file mode 100644 index 000000000..d516ced78 --- /dev/null +++ b/Week3/homework/Masoud/meditationApp/style.css @@ -0,0 +1,84 @@ +* { + padding: 0; + margin: 0; + box-sizing: border-box; +} + +.app { + height: 100vh; + display: flex; + justify-content: space-evenly; + align-items: center; +} + +.time-select, +.sound-picker, +.player-container { + height: 80%; + flex: 1; + display: flex; + flex-direction: column; + justify-content: space-evenly; + align-items: center; +} + +.player-container svg { + position: absolute; + height: 50%; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + pointer-events: none; +} + +.time-display { + position: absolute; + bottom: 10%; + color: white; + font-size: 50px; +} + +video { + position: fixed; + top: 0%; + left: 0%; + width: 100%; + z-index: -1; +} + +.time-select button, +.sound-picker button { + color: white; + width: 30%; + height: 10%; + background-color: transparent; + border: 2px solid white; + cursor: pointer; + border-radius: 5px; + font-size: 20px; + transition: all 0.5s ease; +} + +.time-select button:hover { + color: black; + background-color: white; +} + +.sound-picker button { + border: none; + height: 120px; + width: 120px; + border-radius: 50%; + padding: 30px; +} + +.sound-picker button:nth-child(1) { + background-color: #4972a1; +} +.sound-picker button:nth-child(2) { + background-color: #a14f49; +} + +.sound-picker button img { + width: 100%; +} diff --git a/Week3/homework/Masoud/meditationApp/svg/beach.svg b/Week3/homework/Masoud/meditationApp/svg/beach.svg new file mode 100644 index 000000000..48ba1b9e7 --- /dev/null +++ b/Week3/homework/Masoud/meditationApp/svg/beach.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Week3/homework/Masoud/meditationApp/svg/moving-outline.svg b/Week3/homework/Masoud/meditationApp/svg/moving-outline.svg new file mode 100644 index 000000000..3e75b2c41 --- /dev/null +++ b/Week3/homework/Masoud/meditationApp/svg/moving-outline.svg @@ -0,0 +1,3 @@ + + + diff --git a/Week3/homework/Masoud/meditationApp/svg/pause.svg b/Week3/homework/Masoud/meditationApp/svg/pause.svg new file mode 100644 index 000000000..b950b26bc --- /dev/null +++ b/Week3/homework/Masoud/meditationApp/svg/pause.svg @@ -0,0 +1,4 @@ + + + + diff --git a/Week3/homework/Masoud/meditationApp/svg/play.svg b/Week3/homework/Masoud/meditationApp/svg/play.svg new file mode 100644 index 000000000..781afc842 --- /dev/null +++ b/Week3/homework/Masoud/meditationApp/svg/play.svg @@ -0,0 +1,3 @@ + + + diff --git a/Week3/homework/Masoud/meditationApp/svg/rain.svg b/Week3/homework/Masoud/meditationApp/svg/rain.svg new file mode 100644 index 000000000..0a56c9885 --- /dev/null +++ b/Week3/homework/Masoud/meditationApp/svg/rain.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Week3/homework/Masoud/meditationApp/svg/replay.svg b/Week3/homework/Masoud/meditationApp/svg/replay.svg new file mode 100644 index 000000000..91bb750a1 --- /dev/null +++ b/Week3/homework/Masoud/meditationApp/svg/replay.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Week3/homework/Masoud/meditationApp/svg/track-outline.svg b/Week3/homework/Masoud/meditationApp/svg/track-outline.svg new file mode 100644 index 000000000..e2efc9b3e --- /dev/null +++ b/Week3/homework/Masoud/meditationApp/svg/track-outline.svg @@ -0,0 +1,3 @@ + + + diff --git a/Week3/homework/Masoud/meditationApp/video/beach.mp4 b/Week3/homework/Masoud/meditationApp/video/beach.mp4 new file mode 100644 index 000000000..d7c20b5fb Binary files /dev/null and b/Week3/homework/Masoud/meditationApp/video/beach.mp4 differ diff --git a/Week3/homework/Masoud/meditationApp/video/rain.mp4 b/Week3/homework/Masoud/meditationApp/video/rain.mp4 new file mode 100644 index 000000000..cc0a6d0c5 Binary files /dev/null and b/Week3/homework/Masoud/meditationApp/video/rain.mp4 differ diff --git a/Week3/homework/js-exercises/cost-exe5.js b/Week3/homework/js-exercises/cost-exe5.js new file mode 100644 index 000000000..65e762160 --- /dev/null +++ b/Week3/homework/js-exercises/cost-exe5.js @@ -0,0 +1,25 @@ +'use strict' +const cartForParty = { + beer: 1, + chips: 2, + fruits: 3, + dough: 4, + water: 5 +} + +let total = 0; +function calculateTotalPrice(item) { + for (let i = 0; i < Object.keys(item).length; i++) { + + const arrValues = Object.values(item); + total += arrValues[i]; + + }; + const result = console.log(`Total: €${total}`); + return result; +}; + +calculateTotalPrice(cartForParty); + + + diff --git a/Week3/homework/js-exercises/creditCardProject.js b/Week3/homework/js-exercises/creditCardProject.js new file mode 100644 index 000000000..5bea221cd --- /dev/null +++ b/Week3/homework/js-exercises/creditCardProject.js @@ -0,0 +1,62 @@ +'use strict' +function validateCreditNumber(num) { + const array = []; + for(let i = 0; i < num.length; i++){ + array.push(num[i]); + } + + //At least two diffrent numbers should be represented + function similarity(array){ + let firstItem = array[0] + let x = array.filter(elements => elements == firstItem).length != array.length ? false : true; + return x + } + + //The Sum of all the numbers must be greater than 16: + let sum = 0 + const lastNum = array[array.length -1]; + for (let i = 0; i < array.length; i++){ + let arrayInt = parseInt(array[i]) + sum += arrayInt + } + + switch(true){ + + //The length of the number + case num.length !== 16: + console.log(`Invalid! The input ${num} should be 16 characters!`); + break; + + //All characters must be numbers + case num.match(/^[0-9]+$/) == null: + console.log(`Invalid! The input ${num} should contain only numbers!`); + break; + + //At least two diffrent numbers should be represented + case similarity(array) == true: + console.log(`Invalid! The input ${num} should contain at least 2 different types of numbers!`); + break; + + //The last number must be even + case lastNum % 2 !== 0: + console.log(`Invalid! The last number of the input ${num} should be even`); + + break; + + //The Sum of all the numbers must be greater than 16: + case sum < 16: + console.log(`Invalid! The sum of the input ${num} should be more than 16`); + break; + + default: + console.log(`Success! The input ${num} is a valid credit card number!`) + + }; + +}; + + +validateCreditNumber('66666666666561666'); +validateCreditNumber('a92332119c011112'); +validateCreditNumber('4444444444444441'); +validateCreditNumber('1111111111111110'); \ No newline at end of file diff --git a/Week3/homework/js-exercises/dog-exe2.js b/Week3/homework/js-exercises/dog-exe2.js new file mode 100644 index 000000000..d70b1ebee --- /dev/null +++ b/Week3/homework/js-exercises/dog-exe2.js @@ -0,0 +1,8 @@ +function calculateDogAge(age) { + const doggyage = age * 7; + const result = console.log(doggyage); + return result; +}; +calculateDogAge(3); +calculateDogAge(2); +calculateDogAge(4); diff --git a/Week3/homework/js-exercises/fortune-exe3.js b/Week3/homework/js-exercises/fortune-exe3.js new file mode 100644 index 000000000..734978de7 --- /dev/null +++ b/Week3/homework/js-exercises/fortune-exe3.js @@ -0,0 +1,16 @@ +node const numChildren = [1, 2, 3, 4, 5]; +const partnerNames = ['Ali', 'Amir', 'Lili', 'Mina', 'Masood']; +const locations = ['Iran', 'USA', 'Holland', 'UK', 'Jordan']; +const jobs = ['Doctor', 'Programmer', 'Killer', 'Police', 'President']; +function tellFortune(numChildren, partnerNames, locations, jobs){ + const randomNum = numChildren[Math.floor(Math.random() * numChildren.length)]; + const randomName = partnerNames[Math.floor(Math.random() * partnerNames.length)]; + const randomLocation = locations[Math.floor(Math.random() * locations.length)]; + const randomJob = jobs[Math.floor(Math.random() * jobs.length)]; + + console.log(`You will be a ${randomJob} in ${randomLocation}, married to ${randomName} with ${randomNum} kids.`) +}; + +tellFortune(numChildren, partnerNames, locations, jobs); +tellFortune(numChildren, partnerNames, locations, jobs); +tellFortune(numChildren, partnerNames, locations, jobs); \ No newline at end of file diff --git a/Week3/homework/js-exercises/noer-ex1.js b/Week3/homework/js-exercises/noer-ex1.js new file mode 100644 index 000000000..6ee09bd26 --- /dev/null +++ b/Week3/homework/js-exercises/noer-ex1.js @@ -0,0 +1,10 @@ +'use strict' +const compliments = ["great", "amazing", "wonderful", "lamentable", "attractive", "merciful", "fair" , "spectacular", "dynamic", "elegant"]; +function giveCompliment(name) { + + const randCompliment = compliments[Math.floor(Math.random() * compliments.length)]; + const result = console.log(`You are ${randCompliment}, ${name}!`) + return result; //Am I using return correctly here? +}; +giveCompliment('ali') + diff --git a/Week3/homework/js-exercises/shopping-exe4.js b/Week3/homework/js-exercises/shopping-exe4.js new file mode 100644 index 000000000..74b3a9175 --- /dev/null +++ b/Week3/homework/js-exercises/shopping-exe4.js @@ -0,0 +1,16 @@ +'use strict' +const shoppingCart = ['bananas', 'milk']; +function addToShoppingCart(item){ + shoppingCart.push(item); + for(let i = 0; i < shoppingCart.length; i++) { + if (shoppingCart.length > 3) { + shoppingCart.shift(); + } +}; + const result = console.log(`You bought ${shoppingCart}!`); + return result; +}; +addToShoppingCart('chocolate'); +addToShoppingCart('waffles'); +addToShoppingCart('tea'); +addToShoppingCart('apple'); \ No newline at end of file diff --git a/Week3/text.js b/Week3/text.js new file mode 100644 index 000000000..e69de29bb