Skip to content

Commit 2fa60e6

Browse files
Alex JamshidiAlex Jamshidi
authored andcommitted
added printTim function
1 parent 439144a commit 2fa60e6

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

Sprint-3/alarmclock/alarmclock.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function setAlarm() {
22
timeRemaining = document.getElementById("timeRemaining")
3-
alarmSet = document.getElementById("alarmSet").value
4-
3+
timeSet = document.getElementById("alarmSet").value
4+
const time = convertTime(timeSet)
55

66

77

@@ -11,7 +11,7 @@ function setAlarm() {
1111

1212
function countdown(time) {
1313
setInterval(() => {
14-
14+
1515
}, 1000)
1616
}
1717

@@ -23,6 +23,16 @@ function convertTime(timeSeconds) {
2323
return [minutes, seconds];
2424
}
2525

26+
function printTime(time) {
27+
const paddedHours = String(time[0]).padStart(2, "0");
28+
const paddedSeconds = String(time[1]).padStart(2, "0");
29+
return paddedHours + ":" + paddedSeconds;
30+
}
31+
32+
printTime([50,40])
33+
printTime([50,4])
34+
printTime([5,40])
35+
2636
convertTime(5000000)
2737
convertTime(50)
2838
convertTime(500)

0 commit comments

Comments
 (0)