Skip to content

Commit 8b179f7

Browse files
timeConverter.js fixed single hour time pm formats; added edge cases hour === 12 for noon
1 parent bcf5419 commit 8b179f7

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
@@ -9,13 +9,17 @@ function formatAs12HourClock(time) {
99
else if (hours > 12) {
1010
return `${hours - 12}:${minutes} pm`;
1111
}
12+
else if (hours === 12) {
13+
return `12:${minutes} pm`;
14+
}
15+
1216
else if (hours > 9){
1317
return `${hours}:${minutes} am`
1418
}
1519
else if (hours < 1) {
1620
return `12:${minutes} am`;
1721
}
18-
return `0${hours}:${minutes} am`;
22+
return `${hours}:${minutes} am`;
1923
}
2024

2125

0 commit comments

Comments
 (0)