diff --git a/Week1/.vscode/settings.json b/Week1/.vscode/settings.json new file mode 100644 index 000000000..6f3a2913e --- /dev/null +++ b/Week1/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/Week1/js-exercises/CatWalk/cat-walk.gif b/Week1/js-exercises/CatWalk/cat-walk.gif new file mode 100644 index 000000000..65e1d59dd Binary files /dev/null and b/Week1/js-exercises/CatWalk/cat-walk.gif differ diff --git a/Week1/js-exercises/ex5-catWalk.html b/Week1/js-exercises/CatWalk/ex5-catWalk.html similarity index 61% rename from Week1/js-exercises/ex5-catWalk.html rename to Week1/js-exercises/CatWalk/ex5-catWalk.html index 0f04792f7..07ff7534e 100644 --- a/Week1/js-exercises/ex5-catWalk.html +++ b/Week1/js-exercises/CatWalk/ex5-catWalk.html @@ -7,8 +7,8 @@ - + diff --git a/Week1/js-exercises/ex5-catWalk.js b/Week1/js-exercises/CatWalk/ex5-catWalk.js similarity index 65% rename from Week1/js-exercises/ex5-catWalk.js rename to Week1/js-exercises/CatWalk/ex5-catWalk.js index 309eca0eb..8bfc725f4 100644 --- a/Week1/js-exercises/ex5-catWalk.js +++ b/Week1/js-exercises/CatWalk/ex5-catWalk.js @@ -1,5 +1,5 @@ /** - + ** Exercise 5: The cat walk ** Starting with an HTML, which has a single img tag of an animated GIF of a cat walking. @@ -9,5 +9,29 @@ 4. Call that function every 50 milliseconds.Your cat should now be moving across the screen from left to right.Hurrah! 5. When the cat reaches the right - hand of the screen, restart them at the left hand side("0px").So they should keep walking from left to right across the screen, forever and ever. 6. When the cat reaches the middle of the screen, replace the img with an image of a cat dancing(use this URL: https: //tenor.com/StFI.gif), keep it dancing for 5 seconds, and then replace the img with the original image and have it continue the walk. - -*/ \ No newline at end of file + +*/ +const catImg = document.querySelector('body img'); +let point = -300; +app(); + +function app() { + const walking = setInterval(catWalk, 5); + + function catWalk() { + if (point > screen.width) { + point = -300; + } else if (point == screen.width / 2 - 150) { + clearInterval(walking); + catImg.src = 'tenor.gif'; + setTimeout(() => { + catImg.src = './cat-walk.gif'; + point++; + app(); + }, 5000); + } else { + catImg.style.left = `${point}px`; + point++; + } + } +} diff --git a/Week1/js-exercises/CatWalk/tenor.gif b/Week1/js-exercises/CatWalk/tenor.gif new file mode 100644 index 000000000..7575cfb98 Binary files /dev/null and b/Week1/js-exercises/CatWalk/tenor.gif differ diff --git a/Week2/project/index.html b/Week1/js-exercises/What is the time/ex4-whatsTheTime.html similarity index 50% rename from Week2/project/index.html rename to Week1/js-exercises/What is the time/ex4-whatsTheTime.html index 664b242d3..57c3961c5 100644 --- a/Week2/project/index.html +++ b/Week1/js-exercises/What is the time/ex4-whatsTheTime.html @@ -1,17 +1,18 @@ + + - - Pomodoro Clock + Time -
-
- + - \ No newline at end of file diff --git a/Week1/js-exercises/What is the time/ex4-whatsTheTime.js b/Week1/js-exercises/What is the time/ex4-whatsTheTime.js new file mode 100644 index 000000000..d34775ebb --- /dev/null +++ b/Week1/js-exercises/What is the time/ex4-whatsTheTime.js @@ -0,0 +1,24 @@ +/** + +** Exercise 4: What 's the time? ** + +Why wear a watch when you can check the time, live in your webpage ? + +1. Create a basic HTML file +2. in the HTML file Include a script tag and link the JavaScript file +3. Inside the JS file, write a function that adds the current time to the webpage. Make sure it 's written in the HH:MM:ss notation (hour, minute, second). Hint: use `setInterval()` to make sure the time stays current +4. Have the function execute when it 's loading in the browser + +*/ +const timeP = document.createElement('p'); + +function displayCurrentTime() { + // your code goes in here + const now = new Date(); + timeP.innerText = `${now.getHours()} : ${now.getMinutes()} : ${now.getSeconds()}`; + document.body.appendChild(timeP); + timeP.style.textAlign = 'center'; + timeP.style.fontSize = '24px'; +} + +setInterval(displayCurrentTime, 1000); diff --git a/Week1/js-exercises/ex1-bookList.html b/Week1/js-exercises/ex1-bookList.html index b3864ac18..498ae9a16 100644 --- a/Week1/js-exercises/ex1-bookList.html +++ b/Week1/js-exercises/ex1-bookList.html @@ -12,6 +12,8 @@

My Book List

+ + \ No newline at end of file diff --git a/Week1/js-exercises/ex1-bookList.js b/Week1/js-exercises/ex1-bookList.js index 2db54ba5e..d3eb71cda 100644 --- a/Week1/js-exercises/ex1-bookList.js +++ b/Week1/js-exercises/ex1-bookList.js @@ -1,42 +1,71 @@ /** - - ** Exercise 1: The book list ** - I 'd like to display my three favorite books inside a nice webpage! - - 1. Iterate through the array of books. - 2. For each book, create a `

` - element with the book title and author and append it to the page. - 3. Use a `