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/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/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