Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ffbb8e1

Browse files
committed
Add week5 classwork
1 parent b27480a commit ffbb8e1

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<html>
2+
<head>
3+
<title>Week 5</title>
4+
</head>
5+
<body>
6+
<button id="button">Click</button>
7+
<script src="index.js" type="text/javascript"></script>
8+
</body>
9+
</html>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// PART 1
2+
// Revising listeners
3+
4+
function handleClick(){
5+
console.log("Click")
6+
}
7+
8+
function handleClick2(){
9+
console.log("Click2")
10+
}
11+
12+
document.getElementById("button")
13+
.addEventListener("click", handleClick);
14+
15+
document.getElementById("button")
16+
.addEventListener("click", handleClick2);
17+
18+
document.getElementById("button")
19+
.removeEventListener("click", handleClick2);
20+
21+
console.log("OK")
22+
23+
// PART 2
24+
// Timeout and Interval
25+
26+
// const intervalID = setInterval(() => {
27+
// console.log("First")
28+
// }, 1000)
29+
30+
// clearInterval(intervalID)
31+
32+
// PART 3
33+
// Implementing timer as an example
34+
35+
// document.getElementById("button")
36+
// .addEventListener("click", () => {
37+
// console.log("Click")
38+
// let x = 1;
39+
// const intervalID = setInterval(() => {
40+
// console.log(x);
41+
// x++;
42+
// if(x > 10)
43+
// clearInterval(intervalID);
44+
// }, 300)
45+
// });
46+
47+
// PART 4
48+
// Implementing timer as a packaged script
49+
50+
// function createTimer(times, tick, onTick, finish){
51+
// let count = 0;
52+
// const id = setInterval(() =>{
53+
// count++;
54+
// onTick();
55+
// if(count == times){
56+
// clearInterval(id);
57+
// finish();
58+
// }
59+
// }, tick);
60+
// }
61+
62+
// let i = 20;
63+
64+
// const eachTime = () =>{
65+
// console.log(i);
66+
// i--;
67+
// }
68+
69+
// const onFinish = () => {
70+
// console.log("Finished")
71+
// }
72+
73+
// createTimer(20, 300, eachTime, onFinish)

0 commit comments

Comments
 (0)