From 215c676ef913f29a363de601658756a8c0cd962f Mon Sep 17 00:00:00 2001 From: Amirhossein Date: Sun, 22 Nov 2020 11:16:29 +0330 Subject: [PATCH 01/15] ex1 added --- Week2/js-exercises/ex1-oddOnesOut.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Week2/js-exercises/ex1-oddOnesOut.js b/Week2/js-exercises/ex1-oddOnesOut.js index 4f42050ac..1d238d7ca 100644 --- a/Week2/js-exercises/ex1-oddOnesOut.js +++ b/Week2/js-exercises/ex1-oddOnesOut.js @@ -18,4 +18,23 @@ 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 => { + if(number % 2 === 0){ + let even = number * 2; //This gives me the answer but when it return the even, answers will got back to normal! Why it's like this? + return even; + } + +}); +console.log(evenDouble); + +//Map Method: +const evenNum = myNumbers.map(number => { + if(number % 2 === 0) { + return number *2; + }; +}); +console.log(evenNum); \ No newline at end of file From e6bc6d49a9ba1e8d8575bfec070556dcbd698bdc Mon Sep 17 00:00:00 2001 From: Amirhossein Date: Mon, 23 Nov 2020 09:34:36 +0330 Subject: [PATCH 02/15] ex1 modified --- Week2/js-exercises/ex1-oddOnesOut.js | 17 ++++------------- Week2/js-exercises/ex2-whatsYourMondayWorth.js | 1 + 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/Week2/js-exercises/ex1-oddOnesOut.js b/Week2/js-exercises/ex1-oddOnesOut.js index 1d238d7ca..170f9d64b 100644 --- a/Week2/js-exercises/ex1-oddOnesOut.js +++ b/Week2/js-exercises/ex1-oddOnesOut.js @@ -22,19 +22,10 @@ const myNumbers = [1, 2, 3, 4]; //Filter MEthod: -const evenDouble = myNumbers.filter(number => { - if(number % 2 === 0){ - let even = number * 2; //This gives me the answer but when it return the even, answers will got back to normal! Why it's like this? - return even; - } +const evenDouble = myNumbers + .filter(number => (number % 2 === 0)) + .map(number => number *2 ) + // let even = number * 2; //This gives me the answer but when it return the even, answers will got back to normal! Why it's like this? -}); console.log(evenDouble); -//Map Method: -const evenNum = myNumbers.map(number => { - if(number % 2 === 0) { - return number *2; - }; -}); -console.log(evenNum); \ No newline at end of file diff --git a/Week2/js-exercises/ex2-whatsYourMondayWorth.js b/Week2/js-exercises/ex2-whatsYourMondayWorth.js index 47cea70ba..d594ca3fa 100644 --- a/Week2/js-exercises/ex2-whatsYourMondayWorth.js +++ b/Week2/js-exercises/ex2-whatsYourMondayWorth.js @@ -14,6 +14,7 @@ function dayWorth(tasks, hourlyRate) { // put your code in here, the function does returns a euro formatted string + } const mondayTasks = [{ From d0d5f99508599681f960fa904d471e928574762d Mon Sep 17 00:00:00 2001 From: Amirhossein Date: Mon, 23 Nov 2020 09:40:42 +0330 Subject: [PATCH 03/15] ex1 modified --- Week2/js-exercises/ex1-oddOnesOut.js | 2 +- Week2/js-exercises/ex2-whatsYourMondayWorth.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Week2/js-exercises/ex1-oddOnesOut.js b/Week2/js-exercises/ex1-oddOnesOut.js index 170f9d64b..e216705c3 100644 --- a/Week2/js-exercises/ex1-oddOnesOut.js +++ b/Week2/js-exercises/ex1-oddOnesOut.js @@ -25,7 +25,7 @@ const myNumbers = [1, 2, 3, 4]; const evenDouble = myNumbers .filter(number => (number % 2 === 0)) .map(number => number *2 ) - // let even = number * 2; //This gives me the answer but when it return the even, answers will got back to normal! Why it's like this? + console.log(evenDouble); diff --git a/Week2/js-exercises/ex2-whatsYourMondayWorth.js b/Week2/js-exercises/ex2-whatsYourMondayWorth.js index d594ca3fa..14733ed94 100644 --- a/Week2/js-exercises/ex2-whatsYourMondayWorth.js +++ b/Week2/js-exercises/ex2-whatsYourMondayWorth.js @@ -14,7 +14,8 @@ function dayWorth(tasks, hourlyRate) { // put your code in here, the function does returns a euro formatted string - + const TDur = mondayTasks.map(duration); + console.log(TDur) } const mondayTasks = [{ From 433e60e8faa69f551c44a8365b144d68e1b83311 Mon Sep 17 00:00:00 2001 From: Amirhossein Date: Mon, 23 Nov 2020 10:06:59 +0330 Subject: [PATCH 04/15] ex2 is added --- Week2/js-exercises/ex2-whatsYourMondayWorth.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Week2/js-exercises/ex2-whatsYourMondayWorth.js b/Week2/js-exercises/ex2-whatsYourMondayWorth.js index 14733ed94..9a4268a12 100644 --- a/Week2/js-exercises/ex2-whatsYourMondayWorth.js +++ b/Week2/js-exercises/ex2-whatsYourMondayWorth.js @@ -14,8 +14,14 @@ function dayWorth(tasks, hourlyRate) { // put your code in here, the function does returns a euro formatted string - const TDur = mondayTasks.map(duration); - console.log(TDur) + 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 = [{ From 553fc62b83b3884dec5b17802f748402d7a2cd5e Mon Sep 17 00:00:00 2001 From: Amirhossein Date: Mon, 23 Nov 2020 10:18:36 +0330 Subject: [PATCH 05/15] ex3 is added --- Week2/js-exercises/ex3-lemonAllergy.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Week2/js-exercises/ex3-lemonAllergy.js b/Week2/js-exercises/ex3-lemonAllergy.js index 54ac8da04..e8ac7c392 100644 --- a/Week2/js-exercises/ex3-lemonAllergy.js +++ b/Week2/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']; From f68507eb413644a31e8f016c69183ce1ecaaf978 Mon Sep 17 00:00:00 2001 From: Amirhossein Date: Mon, 23 Nov 2020 10:27:17 +0330 Subject: [PATCH 06/15] ex4 is added --- Week2/js-exercises/ex4-collectiveAge.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Week2/js-exercises/ex4-collectiveAge.js b/Week2/js-exercises/ex4-collectiveAge.js index 1ab2bd1f5..3279752ed 100644 --- a/Week2/js-exercises/ex4-collectiveAge.js +++ b/Week2/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 = [{ From 46c3901e347ee3de832b719209c64d293750eb5e Mon Sep 17 00:00:00 2001 From: Amirhossein Date: Mon, 23 Nov 2020 11:49:55 +0330 Subject: [PATCH 07/15] ex5 is added --- Week2/js-exercises/ex5-myFavoriteHobbies.html | 16 ++++++++++++---- Week2/js-exercises/ex5-myFavoriteHobbies.js | 18 ++++++++++++++++-- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/Week2/js-exercises/ex5-myFavoriteHobbies.html b/Week2/js-exercises/ex5-myFavoriteHobbies.html index 06ab17d45..66d5a2ecf 100644 --- a/Week2/js-exercises/ex5-myFavoriteHobbies.html +++ b/Week2/js-exercises/ex5-myFavoriteHobbies.html @@ -1,5 +1,13 @@ - + + + + + + Codestin Search App + + + - - - \ No newline at end of file + + + diff --git a/Week2/js-exercises/ex5-myFavoriteHobbies.js b/Week2/js-exercises/ex5-myFavoriteHobbies.js index 289c68380..9ddce830f 100644 --- a/Week2/js-exercises/ex5-myFavoriteHobbies.js +++ b/Week2/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 From dde1798a0c40b5056ab1147be401689da0e4ce98 Mon Sep 17 00:00:00 2001 From: Amirhossein Date: Wed, 25 Nov 2020 23:02:49 +0330 Subject: [PATCH 08/15] counter is fixed - timer is added --- Week2/project/index.html | 24 +++++++++ Week2/project/index.js | 111 ++++++++++++++++++++++++++++++++++++++- Week2/project/index2.js | 84 +++++++++++++++++++++++++++++ Week2/project/style.css | 77 +++++++++++++++++++++++++++ 4 files changed, 295 insertions(+), 1 deletion(-) create mode 100644 Week2/project/index2.js create mode 100644 Week2/project/style.css diff --git a/Week2/project/index.html b/Week2/project/index.html index 664b242d3..f4fadb50f 100644 --- a/Week2/project/index.html +++ b/Week2/project/index.html @@ -4,14 +4,38 @@ + + + Codestin Search App
+

Pomodoro Clock

+

Session Length

+
+ + + +

25

+ +
+
+

Session

+ +
25:00
+
+
+ + + +
+
+ \ No newline at end of file diff --git a/Week2/project/index.js b/Week2/project/index.js index 5b306f0f2..8faf4d4e4 100644 --- a/Week2/project/index.js +++ b/Week2/project/index.js @@ -7,4 +7,113 @@ 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 + */ + +const arrowUp = document.querySelector('.fa-arrow-up'); +const arrowDown = document.querySelector('.fa-arrow-down'); +const startTime = document.querySelector('.start-time'); +const playBtn = document.querySelector('.fa-play'); +const pauseBtn = document.querySelector('.fa-pause'); +const minutesTimer = document.querySelector('.minutes'); +const secondsTimer = document.querySelector('.seconds'); + +let intialTime = 25; +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 = 1; + }; + +}; + + + +let seconds = 60; +function countDownSeconds() { + seconds--; + secondsTimer.innerHTML = seconds; + if (seconds == 0) { + seconds = 60; + + } +}; + + +// let countDown = setInterval(countDownSeconds, 1000) + + +let minutes = intialTime +function countDownMinutes() { + minutes-- + minutesTimer.innerHTML = minutes; + if (minutes === 0){ + clearInterval(counterRun) + + }; +}; +// let clockTimer = setInterval(countDownMinutes, 60000) +let isClockRunning = false; + +function counterRun() { + setInterval(countDownSeconds, 1000); + setInterval(countDownMinutes, 60000); + + }; + + +// START +playBtn.addEventListener('click', () => { + counterRun(); + +}) + +// PAUSE +// pauseBtn.addEventListener('click', () => { +// toggleClock(); +// }) + +// // STOP +// stopBtn.addEventListener('click', () => { +// toggleClock(true); +// }) + + + + + +// const toggleClock = (reset) => { +// if (reset) { +// // STOP THE TIMER +// } else { +// if (isClockRunning === true) { +// // PAUSE THE TIMER +// isClockRunning = false; +// } else { +// // START THE TIMER +// isClockRunning = true; +// clockTimer = setInterval(countDownMinutes, 60000) + +// } +// } +// } + +//Event Listener +arrowUp.addEventListener('click', addMinute); +arrowDown.addEventListener('click', minusMinute); +// playBtn.addEventListener('click', countDown); + + + \ No newline at end of file diff --git a/Week2/project/index2.js b/Week2/project/index2.js new file mode 100644 index 000000000..86f829b26 --- /dev/null +++ b/Week2/project/index2.js @@ -0,0 +1,84 @@ +const arrowUp = document.querySelector('.fa-arrow-up'); +const arrowDown = document.querySelector('.fa-arrow-down'); +const pomodoroTimer = document.querySelector('.timer') +const startTime = document.querySelector('.start-time'); +const playBtn = document.querySelector('.fa-play'); +const pauseBtn = document.querySelector('.fa-pause'); +const stopBtn = document.querySelector('.fa-stop'); +const minutesTimer = document.querySelector('.minutes'); +const secondsTimer = document.querySelector('.seconds'); + + +// START +playBtn.addEventListener('click', () => { + toggleClock(); + }) + + // PAUSE + pauseBtn.addEventListener('click', () => { + toggleClock(); + }) + + // STOP + stopBtn.addEventListener('click', () => { + toggleClock(true); + }) + + let isClockRunning = false; + + // in seconds = 25 mins +let workSessionDuration = 1500; +let currentTimeLeftInSession = 1500; + +// in seconds = 5 mins; +let breakSessionDuration = 300; + + +const toggleClock = reset => { + if (reset) { + // STOP THE TIMER + stopClock() + } else { + if (isClockRunning === true) { + // PAUSE THE TIMER + clearInterval(clockTimer); + isClockRunning = false; + } else { + // START THE TIMER + + isClockRunning = true; + clockTimer = setInterval(() => { + currentTimeLeftInSession-- + displayCurrentTimeLeftInSession(); + }, 1000); + } + } + } + + + const displayCurrentTimeLeftInSession = () => { + const secondsLeft = currentTimeLeftInSession + let result = '' + const seconds = secondsLeft % 60 + const minutes = parseInt(secondsLeft / 60) % 60 + let hours = parseInt(secondsLeft / 3600) + // add leading zeroes if it's less than 10 + function addLeadingZeroes(time) { + return time < 10 ? `0${time}` : time + } + if (hours > 0) result += `${hours}:` + result += `${addLeadingZeroes(minutes)}:${addLeadingZeroes(seconds)}` + pomodoroTimer.innerText = result.toString() + } + + const stopClock = () => { + // 1) reset the timer we set + clearInterval(clockTimer) + // 2) update our variable to know that the timer is stopped + isClockRunning = false + // reset the time left in the session to its original state + currentTimeLeftInSession = workSessionDuration + // update the timer displayed + displayCurrentTimeLeftInSession() + } + \ No newline at end of file diff --git a/Week2/project/style.css b/Week2/project/style.css new file mode 100644 index 000000000..0b4f9791a --- /dev/null +++ b/Week2/project/style.css @@ -0,0 +1,77 @@ +* { + 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; +} From 6c75d23173ca6cee6398951359de356fdcdd67f6 Mon Sep 17 00:00:00 2001 From: Amirhossein Date: Sat, 28 Nov 2020 00:17:19 +0330 Subject: [PATCH 09/15] Pomodoro project added - some bugs need to fix --- Week2/project/index.js | 124 +++++++++++++++++----------------------- Week2/project/index2.js | 84 --------------------------- 2 files changed, 54 insertions(+), 154 deletions(-) delete mode 100644 Week2/project/index2.js diff --git a/Week2/project/index.js b/Week2/project/index.js index 8faf4d4e4..63ee8144d 100644 --- a/Week2/project/index.js +++ b/Week2/project/index.js @@ -12,12 +12,48 @@ 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'); -const minutesTimer = document.querySelector('.minutes'); -const secondsTimer = document.querySelector('.seconds'); +let minutesTimer = document.querySelector('.minutes'); +let secondsTimer = document.querySelector('.seconds'); + let intialTime = 25; + +arrowUp.addEventListener('click', addMinute); +arrowDown.addEventListener('click', minusMinute); +playBtn.addEventListener('click', counterRun); +stopBtn.addEventListener('click', stopTimer) + + +function counterRun() { + pauseBtn.addEventListener('click', counterPause); + stopBtn.removeEventListener('click', stopTimer); + playBtn.removeEventListener('click', counterRun) + const counterStart = setInterval(timer, 10); + + function counterPause() { + clearInterval(counterStart); + playBtn.addEventListener('click', counterRun); + stopBtn.addEventListener('click', stopTimer) + + } + + }; + + + function stopTimer(){ + + minutesTimer.textContent = 25; + secondsTimer.textContent = '00'; + startTime.textContent = 25; + + + } + + function addMinute() { intialTime++; startTime.innerHTML = intialTime; @@ -26,7 +62,7 @@ function addMinute() { intialTime = 0; }; - + }; function minusMinute() { @@ -34,86 +70,34 @@ function minusMinute() { startTime.innerHTML = intialTime; minutesTimer.innerHTML = intialTime; if(intialTime == 0){ - intialTime = 1; + intialTime = 60; }; }; - - -let seconds = 60; -function countDownSeconds() { - seconds--; - secondsTimer.innerHTML = seconds; - if (seconds == 0) { - seconds = 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--; - } -}; - - -// let countDown = setInterval(countDownSeconds, 1000) - - -let minutes = intialTime -function countDownMinutes() { - minutes-- - minutesTimer.innerHTML = minutes; - if (minutes === 0){ - clearInterval(counterRun) + } else if (minutesTimer.textContent == 0 && secondsTimer.textContent == 0){ + timerText.textContent = "Time's Up!"; - }; -}; -// let clockTimer = setInterval(countDownMinutes, 60000) -let isClockRunning = false; - -function counterRun() { - setInterval(countDownSeconds, 1000); - setInterval(countDownMinutes, 60000); - - }; - - -// START -playBtn.addEventListener('click', () => { - counterRun(); - -}) - -// PAUSE -// pauseBtn.addEventListener('click', () => { -// toggleClock(); -// }) - -// // STOP -// stopBtn.addEventListener('click', () => { -// toggleClock(true); -// }) + } + stopBtn.addEventListener('click', stopTimer); + +} -// const toggleClock = (reset) => { -// if (reset) { -// // STOP THE TIMER -// } else { -// if (isClockRunning === true) { -// // PAUSE THE TIMER -// isClockRunning = false; -// } else { -// // START THE TIMER -// isClockRunning = true; -// clockTimer = setInterval(countDownMinutes, 60000) -// } -// } -// } -//Event Listener -arrowUp.addEventListener('click', addMinute); -arrowDown.addEventListener('click', minusMinute); -// playBtn.addEventListener('click', countDown); \ No newline at end of file diff --git a/Week2/project/index2.js b/Week2/project/index2.js deleted file mode 100644 index 86f829b26..000000000 --- a/Week2/project/index2.js +++ /dev/null @@ -1,84 +0,0 @@ -const arrowUp = document.querySelector('.fa-arrow-up'); -const arrowDown = document.querySelector('.fa-arrow-down'); -const pomodoroTimer = document.querySelector('.timer') -const startTime = document.querySelector('.start-time'); -const playBtn = document.querySelector('.fa-play'); -const pauseBtn = document.querySelector('.fa-pause'); -const stopBtn = document.querySelector('.fa-stop'); -const minutesTimer = document.querySelector('.minutes'); -const secondsTimer = document.querySelector('.seconds'); - - -// START -playBtn.addEventListener('click', () => { - toggleClock(); - }) - - // PAUSE - pauseBtn.addEventListener('click', () => { - toggleClock(); - }) - - // STOP - stopBtn.addEventListener('click', () => { - toggleClock(true); - }) - - let isClockRunning = false; - - // in seconds = 25 mins -let workSessionDuration = 1500; -let currentTimeLeftInSession = 1500; - -// in seconds = 5 mins; -let breakSessionDuration = 300; - - -const toggleClock = reset => { - if (reset) { - // STOP THE TIMER - stopClock() - } else { - if (isClockRunning === true) { - // PAUSE THE TIMER - clearInterval(clockTimer); - isClockRunning = false; - } else { - // START THE TIMER - - isClockRunning = true; - clockTimer = setInterval(() => { - currentTimeLeftInSession-- - displayCurrentTimeLeftInSession(); - }, 1000); - } - } - } - - - const displayCurrentTimeLeftInSession = () => { - const secondsLeft = currentTimeLeftInSession - let result = '' - const seconds = secondsLeft % 60 - const minutes = parseInt(secondsLeft / 60) % 60 - let hours = parseInt(secondsLeft / 3600) - // add leading zeroes if it's less than 10 - function addLeadingZeroes(time) { - return time < 10 ? `0${time}` : time - } - if (hours > 0) result += `${hours}:` - result += `${addLeadingZeroes(minutes)}:${addLeadingZeroes(seconds)}` - pomodoroTimer.innerText = result.toString() - } - - const stopClock = () => { - // 1) reset the timer we set - clearInterval(clockTimer) - // 2) update our variable to know that the timer is stopped - isClockRunning = false - // reset the time left in the session to its original state - currentTimeLeftInSession = workSessionDuration - // update the timer displayed - displayCurrentTimeLeftInSession() - } - \ No newline at end of file From 6ba80333a360145dffeaa65e6268a0cc9c9eb706 Mon Sep 17 00:00:00 2001 From: Amirhossein Date: Sat, 28 Nov 2020 00:18:28 +0330 Subject: [PATCH 10/15] Timer time is fixed --- Week2/project/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Week2/project/index.js b/Week2/project/index.js index 63ee8144d..336d329be 100644 --- a/Week2/project/index.js +++ b/Week2/project/index.js @@ -32,7 +32,7 @@ function counterRun() { pauseBtn.addEventListener('click', counterPause); stopBtn.removeEventListener('click', stopTimer); playBtn.removeEventListener('click', counterRun) - const counterStart = setInterval(timer, 10); + const counterStart = setInterval(timer, 1000); function counterPause() { clearInterval(counterStart); @@ -89,7 +89,7 @@ function timer() { } - stopBtn.addEventListener('click', stopTimer); + } From 0152fa7e91bf5d9ec8b30caa17ae68b317a0d9f0 Mon Sep 17 00:00:00 2001 From: Amirhossein Date: Sat, 28 Nov 2020 16:39:15 +0330 Subject: [PATCH 11/15] Pomodoro project is finished and added --- Week2/project/index.html | 2 +- Week2/project/index.js | 28 +++++++++++++++++++++------- Week2/project/style.css | 3 +++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Week2/project/index.html b/Week2/project/index.html index f4fadb50f..c5bc84959 100644 --- a/Week2/project/index.html +++ b/Week2/project/index.html @@ -24,7 +24,7 @@

25

Session

-
25:00
+
25:00
diff --git a/Week2/project/index.js b/Week2/project/index.js index 336d329be..ccfc6173d 100644 --- a/Week2/project/index.js +++ b/Week2/project/index.js @@ -18,6 +18,7 @@ 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; @@ -27,12 +28,12 @@ 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) - const counterStart = setInterval(timer, 1000); + counterStart = setInterval(timer, 1); function counterPause() { clearInterval(counterStart); @@ -44,12 +45,19 @@ function counterRun() { }; + + function stopTimer(){ - minutesTimer.textContent = 25; - secondsTimer.textContent = '00'; + 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); } @@ -84,8 +92,14 @@ function timer() { secondsTimer.textContent = 59; minutesTimer.textContent--; - } else if (minutesTimer.textContent == 0 && secondsTimer.textContent == 0){ - timerText.textContent = "Time's Up!"; + } else { + minutesTimer.textContent = "Time's Up!"; + secondsTimer.textContent = ""; + dots.textContent = ""; + + // playBtn.removeEventListener('click', counterRun) + stopBtn.addEventListener('click', stopTimer); + clearInterval(counterStart); } diff --git a/Week2/project/style.css b/Week2/project/style.css index 0b4f9791a..a71a871bf 100644 --- a/Week2/project/style.css +++ b/Week2/project/style.css @@ -75,3 +75,6 @@ h3 { .fa-play { margin-right: 30px; } +.fa-pause { + margin-right: 30px; +} From 8d97c0f4804cd1d870758a488ee7351809883e60 Mon Sep 17 00:00:00 2001 From: Amirhossein Date: Mon, 30 Nov 2020 13:52:40 +0330 Subject: [PATCH 12/15] index.js modified --- Week2/project/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Week2/project/index.js b/Week2/project/index.js index ccfc6173d..2e759b864 100644 --- a/Week2/project/index.js +++ b/Week2/project/index.js @@ -33,7 +33,7 @@ function counterRun() { pauseBtn.addEventListener('click', counterPause); stopBtn.removeEventListener('click', stopTimer); playBtn.removeEventListener('click', counterRun) - counterStart = setInterval(timer, 1); + counterStart = setInterval(timer, 1000); function counterPause() { clearInterval(counterStart); @@ -97,7 +97,7 @@ function timer() { secondsTimer.textContent = ""; dots.textContent = ""; - // playBtn.removeEventListener('click', counterRun) + stopBtn.addEventListener('click', stopTimer); clearInterval(counterStart); From 0dcf91821282137bee322db3173deec97353acf5 Mon Sep 17 00:00:00 2001 From: Amirhossein Date: Sat, 5 Dec 2020 14:15:02 +0330 Subject: [PATCH 13/15] AmirHossein folder added --- Week2/{ => AmirHossein}/LESSONPLAN.md | 0 Week2/{ => AmirHossein}/MAKEME.md | 0 Week2/{ => AmirHossein}/README.md | 0 Week2/{ => AmirHossein}/homework/maartjes-work.js | 0 Week2/{ => AmirHossein}/homework/map-filter.js | 0 Week2/{ => AmirHossein}/js-exercises/ex1-oddOnesOut.js | 0 Week2/{ => AmirHossein}/js-exercises/ex2-whatsYourMondayWorth.js | 0 Week2/{ => AmirHossein}/js-exercises/ex3-lemonAllergy.js | 0 Week2/{ => AmirHossein}/js-exercises/ex4-collectiveAge.js | 0 Week2/{ => AmirHossein}/js-exercises/ex5-myFavoriteHobbies.html | 0 Week2/{ => AmirHossein}/js-exercises/ex5-myFavoriteHobbies.js | 0 Week2/{ => AmirHossein}/project/index.html | 0 Week2/{ => AmirHossein}/project/index.js | 0 Week2/{ => AmirHossein}/project/style.css | 0 Week2/{ => AmirHossein}/test/maartjes-work.test.js | 0 Week2/{ => AmirHossein}/test/map-filter.test.js | 0 16 files changed, 0 insertions(+), 0 deletions(-) rename Week2/{ => AmirHossein}/LESSONPLAN.md (100%) rename Week2/{ => AmirHossein}/MAKEME.md (100%) rename Week2/{ => AmirHossein}/README.md (100%) rename Week2/{ => AmirHossein}/homework/maartjes-work.js (100%) rename Week2/{ => AmirHossein}/homework/map-filter.js (100%) rename Week2/{ => AmirHossein}/js-exercises/ex1-oddOnesOut.js (100%) rename Week2/{ => AmirHossein}/js-exercises/ex2-whatsYourMondayWorth.js (100%) rename Week2/{ => AmirHossein}/js-exercises/ex3-lemonAllergy.js (100%) rename Week2/{ => AmirHossein}/js-exercises/ex4-collectiveAge.js (100%) rename Week2/{ => AmirHossein}/js-exercises/ex5-myFavoriteHobbies.html (100%) rename Week2/{ => AmirHossein}/js-exercises/ex5-myFavoriteHobbies.js (100%) rename Week2/{ => AmirHossein}/project/index.html (100%) rename Week2/{ => AmirHossein}/project/index.js (100%) rename Week2/{ => AmirHossein}/project/style.css (100%) rename Week2/{ => AmirHossein}/test/maartjes-work.test.js (100%) rename Week2/{ => AmirHossein}/test/map-filter.test.js (100%) 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 100% rename from Week2/js-exercises/ex1-oddOnesOut.js rename to Week2/AmirHossein/js-exercises/ex1-oddOnesOut.js diff --git a/Week2/js-exercises/ex2-whatsYourMondayWorth.js b/Week2/AmirHossein/js-exercises/ex2-whatsYourMondayWorth.js similarity index 100% rename from Week2/js-exercises/ex2-whatsYourMondayWorth.js rename to Week2/AmirHossein/js-exercises/ex2-whatsYourMondayWorth.js diff --git a/Week2/js-exercises/ex3-lemonAllergy.js b/Week2/AmirHossein/js-exercises/ex3-lemonAllergy.js similarity index 100% rename from Week2/js-exercises/ex3-lemonAllergy.js rename to Week2/AmirHossein/js-exercises/ex3-lemonAllergy.js diff --git a/Week2/js-exercises/ex4-collectiveAge.js b/Week2/AmirHossein/js-exercises/ex4-collectiveAge.js similarity index 100% rename from Week2/js-exercises/ex4-collectiveAge.js rename to Week2/AmirHossein/js-exercises/ex4-collectiveAge.js diff --git a/Week2/js-exercises/ex5-myFavoriteHobbies.html b/Week2/AmirHossein/js-exercises/ex5-myFavoriteHobbies.html similarity index 100% rename from Week2/js-exercises/ex5-myFavoriteHobbies.html rename to Week2/AmirHossein/js-exercises/ex5-myFavoriteHobbies.html diff --git a/Week2/js-exercises/ex5-myFavoriteHobbies.js b/Week2/AmirHossein/js-exercises/ex5-myFavoriteHobbies.js similarity index 100% rename from Week2/js-exercises/ex5-myFavoriteHobbies.js rename to Week2/AmirHossein/js-exercises/ex5-myFavoriteHobbies.js diff --git a/Week2/project/index.html b/Week2/AmirHossein/project/index.html similarity index 100% rename from Week2/project/index.html rename to Week2/AmirHossein/project/index.html diff --git a/Week2/project/index.js b/Week2/AmirHossein/project/index.js similarity index 100% rename from Week2/project/index.js rename to Week2/AmirHossein/project/index.js diff --git a/Week2/project/style.css b/Week2/AmirHossein/project/style.css similarity index 100% rename from Week2/project/style.css rename to Week2/AmirHossein/project/style.css 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 From dbb234ea713bca859509bb4f5a291afb68488702 Mon Sep 17 00:00:00 2001 From: Amirhossein Date: Sat, 5 Dec 2020 14:21:30 +0330 Subject: [PATCH 14/15] Ex2 euro sign in added --- .../AmirHossein/js-exercises/ex2-whatsYourMondayWorth.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Week2/AmirHossein/js-exercises/ex2-whatsYourMondayWorth.js b/Week2/AmirHossein/js-exercises/ex2-whatsYourMondayWorth.js index 9a4268a12..21ddb69c5 100644 --- a/Week2/AmirHossein/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. @@ -19,8 +19,8 @@ function dayWorth(tasks, hourlyRate) { .map(item => item/60) .map(item => item * hourlyRate) .reduce((a,b) => a + b,0) - return totalTime; - + return `€${totalTime}`; + } From 5c80060c441449de13d2a0fb75a3541857ff253f Mon Sep 17 00:00:00 2001 From: Amirhossein Date: Sat, 5 Dec 2020 14:28:11 +0330 Subject: [PATCH 15/15] Bugs fixed --- Week2/AmirHossein/js-exercises/ex1-oddOnesOut.js | 8 ++++---- .../js-exercises/ex2-whatsYourMondayWorth.js | 14 ++++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Week2/AmirHossein/js-exercises/ex1-oddOnesOut.js b/Week2/AmirHossein/js-exercises/ex1-oddOnesOut.js index e216705c3..70e5f64b7 100644 --- a/Week2/AmirHossein/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. @@ -22,10 +22,10 @@ const myNumbers = [1, 2, 3, 4]; //Filter MEthod: -const evenDouble = myNumbers +const evenDouble = myNumbers; .filter(number => (number % 2 === 0)) .map(number => number *2 ) - - + + console.log(evenDouble); diff --git a/Week2/AmirHossein/js-exercises/ex2-whatsYourMondayWorth.js b/Week2/AmirHossein/js-exercises/ex2-whatsYourMondayWorth.js index 21ddb69c5..cc14d0575 100644 --- a/Week2/AmirHossein/js-exercises/ex2-whatsYourMondayWorth.js +++ b/Week2/AmirHossein/js-exercises/ex2-whatsYourMondayWorth.js @@ -15,13 +15,11 @@ 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) + .map(item => item.duration) + .map(item => item / 60) + .map(item => item * hourlyRate) + .reduce((a, b) => a + b, 0); return `€${totalTime}`; - - } const mondayTasks = [{ @@ -42,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));