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 @@
+
+
-
-