Skip to content

Commit 67f93d7

Browse files
author
Aachman Agarwal
committed
Updated files with my comments - Aachman Agarwal
1 parent 75b7f59 commit 67f93d7

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

02-counter/setup/app.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Modifies by Aachman
2+
let count = 0;
3+
const value = document.querySelector("#value");
4+
const btns = document.querySelectorAll(".btn");
5+
6+
btns.forEach(function (btn) {
7+
btn.addEventListener("click", function (e) {
8+
const styles = e.currentTarget.classList;
9+
if (styles.contains("decrease")) {
10+
count--;
11+
} else if (styles.contains("increase")) {
12+
count++;
13+
} else {
14+
count = 0;
15+
}
16+
17+
if (count > 0) {
18+
value.style.color = "green";
19+
}
20+
if (count < 0) {
21+
value.style.color = "red";
22+
}
23+
if (count === 0) {
24+
value.style.color = "#222";
25+
}
26+
value.textContent = count;
27+
});
28+
});

02-counter/setup/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>Counter</title>
6+
<title>Counter by Aachman</title>
77

88
<!-- styles -->
99
<link rel="stylesheet" href="styles.css" />

0 commit comments

Comments
 (0)