Skip to content

Commit ae98f15

Browse files
author
Pretty Taruvinga
committed
Move timeLeft into setAlarm and remove global variable
1 parent e54e3fc commit ae98f15

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Sprint-3/alarmclock/alarmclock.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
let timeLeft = 0;
21
let timer = null;
32

43
function formatTime(seconds) {
@@ -13,6 +12,7 @@ function updateDisplay(timeLeft) {
1312
}
1413

1514
function setAlarm() {
15+
let timeLeft = 0;
1616
const input = document.getElementById("alarmSet").value;
1717

1818
timeLeft = parseInt(input, 10);
@@ -31,6 +31,7 @@ function setAlarm() {
3131
timer = setInterval(() => {
3232
timeLeft--;
3333
updateDisplay(timeLeft);
34+
3435
if (timeLeft <= 0) {
3536
clearInterval(timer);
3637
timer = null;

0 commit comments

Comments
 (0)