Skip to content

Commit eeb1c24

Browse files
committed
Refactor: improve readability of formatTime() function
1 parent cb65771 commit eeb1c24

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

Sprint-3/alarmclock/alarmclock.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ let timeRemaining;
22
let timerInterval;
33

44
function formatTime(time) {
5-
const minutes =
6-
Math.floor(time / 60) < 10
7-
? "0" + Math.floor(time / 60)
8-
: Math.floor(time / 60);
9-
const seconds = time % 60 < 10 ? "0" + (time % 60) : time % 60;
5+
const minutes = String(Math.floor(time / 60)).padStart(2, "0");
6+
const seconds = String(time % 60).padStart(2, "0");
107

118
return `${minutes}:${seconds}`;
129
}

0 commit comments

Comments
 (0)