Skip to content

Commit 29cacc9

Browse files
committed
made sure when input time is 0, alarm still works and added background colour for timer starting at 10
1 parent 8196fd6 commit 29cacc9

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Sprint-3/alarmclock/alarmclock.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
let inputTime = 0;
22
let timer = null;
3+
let changeBgColor = false;
34

45
function setAlarm() {
56
inputTime = Number(document.querySelector("#alarmSet").value);
67

78
if (Number.isInteger(inputTime) && !isNaN(inputTime) && inputTime >= 0) {
89
if (inputTime === 10) {
10+
changeBgColor = true;
11+
} else if (inputTime === 0) {
12+
displayTime(inputTime);
13+
playAlarm();
914
}
1015
displayTime(inputTime);
1116
if (timer) clearInterval(timer);
@@ -30,10 +35,21 @@ function countDown() {
3035

3136
if (inputTime === 0) {
3237
playAlarm();
38+
39+
if (changeBgColor) {
40+
changeColor();
41+
changeBgColor = false;
42+
}
43+
3344
clearInterval(timer);
3445
timer = null;
3546
}
3647
}
48+
49+
function changeColor() {
50+
const bgColor = document.querySelector("div");
51+
bgColor.classList.add("myBgColor");
52+
}
3753
/*
3854
the the value for time remaining
3955
check its a valid time (greater than 00:00)

Sprint-3/alarmclock/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
transform: translate(-50%, -50%);
77
}
88

9+
.myBgColor {
10+
background-color: #f0f8ff;
11+
}
12+
913
#alarmSet {
1014
margin: 20px;
1115
}

0 commit comments

Comments
 (0)