Skip to content

Commit 1d4f08b

Browse files
committed
added a code for converting with min and converting end of midninght
1 parent ab3e5fa commit 1d4f08b

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎format-clock-edge-cases/timeConverter.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function formatAs12HourClock(time) {
2-
2+
const stringHours =time.slice(0,2);
33
const mints = time.slice(-2);
44
const hours = Number(time.slice(0, 2));
55
if (time === "24:00"){
@@ -8,6 +8,10 @@ function formatAs12HourClock(time) {
88
if(time ==="12:00"){
99
return `12:00 pm`
1010
}
11+
if(stringHours == "00"){
12+
return `12:${mints} am`
13+
14+
}
1115
if(hours=== 12) {
1216
return `${hours}:${mints} pm`
1317
}

0 commit comments

Comments
 (0)