diff --git a/Week2/LESSONPLAN.md b/Week2/AmirHossein/LESSONPLAN.md similarity index 100% rename from Week2/LESSONPLAN.md rename to Week2/AmirHossein/LESSONPLAN.md diff --git a/Week2/MAKEME.md b/Week2/AmirHossein/MAKEME.md similarity index 100% rename from Week2/MAKEME.md rename to Week2/AmirHossein/MAKEME.md diff --git a/Week2/README.md b/Week2/AmirHossein/README.md similarity index 100% rename from Week2/README.md rename to Week2/AmirHossein/README.md diff --git a/Week2/homework/maartjes-work.js b/Week2/AmirHossein/homework/maartjes-work.js similarity index 100% rename from Week2/homework/maartjes-work.js rename to Week2/AmirHossein/homework/maartjes-work.js diff --git a/Week2/homework/map-filter.js b/Week2/AmirHossein/homework/map-filter.js similarity index 100% rename from Week2/homework/map-filter.js rename to Week2/AmirHossein/homework/map-filter.js diff --git a/Week2/js-exercises/ex1-oddOnesOut.js b/Week2/AmirHossein/js-exercises/ex1-oddOnesOut.js similarity index 56% rename from Week2/js-exercises/ex1-oddOnesOut.js rename to Week2/AmirHossein/js-exercises/ex1-oddOnesOut.js index 4f42050ac..70e5f64b7 100644 --- a/Week2/js-exercises/ex1-oddOnesOut.js +++ b/Week2/AmirHossein/js-exercises/ex1-oddOnesOut.js @@ -2,7 +2,7 @@ ** Exercise 1: The odd ones out ** - Rewrite the following function using map and filter. + Rewrite the following function using map and filter. Avoid using for loop or forEach. The function should still behave the same. @@ -18,4 +18,14 @@ function doubleEvenNumbers(numbers) { } const myNumbers = [1, 2, 3, 4]; -console.log(doubleEvenNumbers(myNumbers)); // Logs "[4, 8]" to the console \ No newline at end of file +// console.log(doubleEvenNumbers(myNumbers)); // Logs "[4, 8]" to the console + + +//Filter MEthod: +const evenDouble = myNumbers; + .filter(number => (number % 2 === 0)) + .map(number => number *2 ) + + +console.log(evenDouble); + diff --git a/Week2/js-exercises/ex2-whatsYourMondayWorth.js b/Week2/AmirHossein/js-exercises/ex2-whatsYourMondayWorth.js similarity index 77% rename from Week2/js-exercises/ex2-whatsYourMondayWorth.js rename to Week2/AmirHossein/js-exercises/ex2-whatsYourMondayWorth.js index 47cea70ba..cc14d0575 100644 --- a/Week2/js-exercises/ex2-whatsYourMondayWorth.js +++ b/Week2/AmirHossein/js-exercises/ex2-whatsYourMondayWorth.js @@ -1,7 +1,7 @@ /** - + ** Exercise 2: What 's your Monday worth? ** - + Write a function that finds out what your hourly rate on a Monday would be Use the map array function to take out the duration time for each task. Avoid using for loop or forEach. @@ -14,6 +14,12 @@ function dayWorth(tasks, hourlyRate) { // put your code in here, the function does returns a euro formatted string + const totalTime = tasks + .map(item => item.duration) + .map(item => item / 60) + .map(item => item * hourlyRate) + .reduce((a, b) => a + b, 0); + return `€${totalTime}`; } const mondayTasks = [{ @@ -34,5 +40,5 @@ const mondayTasks = [{ }, ]; -console.log(dayWorth(mondayTasks, 25)) -console.log(dayWorth(mondayTasks, 13.37)) \ No newline at end of file +console.log(dayWorth(mondayTasks, 25)); +console.log(dayWorth(mondayTasks, 13.37)); diff --git a/Week2/js-exercises/ex3-lemonAllergy.js b/Week2/AmirHossein/js-exercises/ex3-lemonAllergy.js similarity index 83% rename from Week2/js-exercises/ex3-lemonAllergy.js rename to Week2/AmirHossein/js-exercises/ex3-lemonAllergy.js index 54ac8da04..e8ac7c392 100644 --- a/Week2/js-exercises/ex3-lemonAllergy.js +++ b/Week2/AmirHossein/js-exercises/ex3-lemonAllergy.js @@ -14,6 +14,8 @@ function takeOutLemons(basket) { // your code goes in here. The output is a string + const allergicFruits = basket.filter(item => item !== "Lemon") + return `My mom bought me a fruit basket, containing ${allergicFruits}!`; } const fruitBasket = ['Apple', 'Lemon', 'Grapefruit', 'Lemon', 'Banana', 'Watermelon', 'Lemon']; diff --git a/Week2/js-exercises/ex4-collectiveAge.js b/Week2/AmirHossein/js-exercises/ex4-collectiveAge.js similarity index 85% rename from Week2/js-exercises/ex4-collectiveAge.js rename to Week2/AmirHossein/js-exercises/ex4-collectiveAge.js index 1ab2bd1f5..3279752ed 100644 --- a/Week2/js-exercises/ex4-collectiveAge.js +++ b/Week2/AmirHossein/js-exercises/ex4-collectiveAge.js @@ -10,6 +10,9 @@ function collectiveAge(people) { // return the sum of age for all the people + const ages = people.map(item => item.age) + const sumAges = ages.reduce((a,b) => a + b ,0) + return sumAges; } const hackYourFutureMembers = [{ diff --git a/Week2/AmirHossein/js-exercises/ex5-myFavoriteHobbies.html b/Week2/AmirHossein/js-exercises/ex5-myFavoriteHobbies.html new file mode 100644 index 000000000..66d5a2ecf --- /dev/null +++ b/Week2/AmirHossein/js-exercises/ex5-myFavoriteHobbies.html @@ -0,0 +1,13 @@ + + + + + + Codestin Search App + + + + + + + diff --git a/Week2/js-exercises/ex5-myFavoriteHobbies.js b/Week2/AmirHossein/js-exercises/ex5-myFavoriteHobbies.js similarity index 62% rename from Week2/js-exercises/ex5-myFavoriteHobbies.js rename to Week2/AmirHossein/js-exercises/ex5-myFavoriteHobbies.js index 289c68380..9ddce830f 100644 --- a/Week2/js-exercises/ex5-myFavoriteHobbies.js +++ b/Week2/AmirHossein/js-exercises/ex5-myFavoriteHobbies.js @@ -10,12 +10,26 @@ function createHTMLList(arr) { // your code goes in here -} + + const ulEl = document.createElement('ul'); + document.body.appendChild(ulEl); + const listItem = arr.forEach(element => { + const liEl = document.createElement('li'); + ulEl.appendChild(liEl); + liEl.innerHTML = element; + + + + }); +} const myHobbies = [ 'Meditation', 'Reading', 'Programming', 'Hanging out with friends', 'Going to the gym', -]; \ No newline at end of file + +]; + +createHTMLList(myHobbies); \ No newline at end of file diff --git a/Week2/AmirHossein/project/index.html b/Week2/AmirHossein/project/index.html new file mode 100644 index 000000000..c5bc84959 --- /dev/null +++ b/Week2/AmirHossein/project/index.html @@ -0,0 +1,41 @@ + + + + + + + + + + Codestin Search App + + + +
+

Pomodoro Clock

+

Session Length

+
+ + + +

25

+ +
+
+

Session

+ +
25:00
+
+
+ + + +
+ + +
+ + + + + \ No newline at end of file diff --git a/Week2/AmirHossein/project/index.js b/Week2/AmirHossein/project/index.js new file mode 100644 index 000000000..2e759b864 --- /dev/null +++ b/Week2/AmirHossein/project/index.js @@ -0,0 +1,117 @@ +/** + In this week 's project you'll be making a Pomodoro Clock! + A user can specify how many minutes the timer should be set, and with a click on the play button it starts counting down!If the user wants to pause the timer, they can do so by clicking the pause button. + + If the timer is running, the user can 't change the session length anymore + Use at least 3 functions + Display minutes and seconds + If the timer finishes the timer should be replaced by the message: Time 's up! + * + */ + +const arrowUp = document.querySelector('.fa-arrow-up'); +const arrowDown = document.querySelector('.fa-arrow-down'); +const startTime = document.querySelector('.start-time'); +const timerText = document.querySelector('.timer'); +const playBtn = document.querySelector('.fa-play'); +const stopBtn = document.querySelector('.fa-stop') +const pauseBtn = document.querySelector('.fa-pause'); +let minutesTimer = document.querySelector('.minutes'); +let secondsTimer = document.querySelector('.seconds'); +const dots = document.querySelector('.dots') + + +let intialTime = 25; + +arrowUp.addEventListener('click', addMinute); +arrowDown.addEventListener('click', minusMinute); +playBtn.addEventListener('click', counterRun); +stopBtn.addEventListener('click', stopTimer) + +let counterStart; +function counterRun() { + pauseBtn.addEventListener('click', counterPause); + stopBtn.removeEventListener('click', stopTimer); + playBtn.removeEventListener('click', counterRun) + counterStart = setInterval(timer, 1000); + + function counterPause() { + clearInterval(counterStart); + playBtn.addEventListener('click', counterRun); + stopBtn.addEventListener('click', stopTimer) + + } + + }; + + + + + function stopTimer(){ + + minutesTimer.innerHTML = "25"; + dots.textContent = ":"; + secondsTimer.innerHTML = '00'; + startTime.textContent = 25; + intialTime = 25 + clearInterval(counterStart); + playBtn.addEventListener('click', counterRun); + arrowUp.addEventListener('click', addMinute); + arrowDown.addEventListener('click', minusMinute); + + } + + +function addMinute() { + intialTime++; + startTime.innerHTML = intialTime; + minutesTimer.innerHTML = intialTime; + if(intialTime == 60) { + intialTime = 0; + }; + + +}; + +function minusMinute() { + intialTime--; + startTime.innerHTML = intialTime; + minutesTimer.innerHTML = intialTime; + if(intialTime == 0){ + intialTime = 60; + }; + +}; + +function timer() { + arrowUp.removeEventListener('click', addMinute); + arrowDown.removeEventListener('click', minusMinute); + if (secondsTimer.textContent != 0){ + secondsTimer.textContent--; + } else if (minutesTimer.textContent != 0 && secondsTimer.textContent == 0){ + secondsTimer.textContent = 59; + minutesTimer.textContent--; + + } else { + minutesTimer.textContent = "Time's Up!"; + secondsTimer.textContent = ""; + dots.textContent = ""; + + + stopBtn.addEventListener('click', stopTimer); + clearInterval(counterStart); + + + } + + +} + + + + + + + + + \ No newline at end of file diff --git a/Week2/AmirHossein/project/style.css b/Week2/AmirHossein/project/style.css new file mode 100644 index 000000000..a71a871bf --- /dev/null +++ b/Week2/AmirHossein/project/style.css @@ -0,0 +1,80 @@ +* { + padding: 0; + margin: 0; + box-sizing: border-box; + font-family: 'Titillium Web', sans-serif; +} + +body { + background-color: #1e555c; + +} + +#app { + display: flex; + flex-direction: column; + text-align: center; + margin-top: 40px; + color: white; +} +h1 { + + font-size: 100px; + + +} +h2 { + font-size: 50px; + margin-bottom: 5px; + +} + + +.time-length { + margin-bottom: 10px; + font-size: 40px; + display: flex; + justify-content: center; + flex-direction: row; + /* margin-left: 700px; */ + +} +h3 { + margin: 0 10px 0 10px; +} + +.arrow-btn { + padding-top: 20px; +} + + +.timer-box { + width: 30%; + margin: auto; + margin-bottom: 30px; + padding: 1.5rem; + + border: 10px solid black; + border-radius: 50px; +} + +.session-text { + margin-bottom: 0; +} + + +.timer { + + font-size: 65px; +} + +.function-btn { + font-size: 40px; +} + +.fa-play { + margin-right: 30px; +} +.fa-pause { + margin-right: 30px; +} diff --git a/Week2/test/maartjes-work.test.js b/Week2/AmirHossein/test/maartjes-work.test.js similarity index 100% rename from Week2/test/maartjes-work.test.js rename to Week2/AmirHossein/test/maartjes-work.test.js diff --git a/Week2/test/map-filter.test.js b/Week2/AmirHossein/test/map-filter.test.js similarity index 100% rename from Week2/test/map-filter.test.js rename to Week2/AmirHossein/test/map-filter.test.js diff --git a/Week2/js-exercises/ex5-myFavoriteHobbies.html b/Week2/js-exercises/ex5-myFavoriteHobbies.html deleted file mode 100644 index 06ab17d45..000000000 --- a/Week2/js-exercises/ex5-myFavoriteHobbies.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Week2/project/index.html b/Week2/project/index.html deleted file mode 100644 index 664b242d3..000000000 --- a/Week2/project/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - Codestin Search App - - - -
- -
- - - - \ No newline at end of file diff --git a/Week2/project/index.js b/Week2/project/index.js deleted file mode 100644 index 5b306f0f2..000000000 --- a/Week2/project/index.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - In this week 's project you'll be making a Pomodoro Clock! - A user can specify how many minutes the timer should be set, and with a click on the play button it starts counting down!If the user wants to pause the timer, they can do so by clicking the pause button. - - If the timer is running, the user can 't change the session length anymore - Use at least 3 functions - Display minutes and seconds - If the timer finishes the timer should be replaced by the message: Time 's up! - * - */ \ No newline at end of file