There was an error while loading. Please reload this page.
1 parent 508e466 commit 92cdff7Copy full SHA for 92cdff7
1 file changed
Sprint-3/5-stretch-extend/format-time.js
@@ -10,7 +10,10 @@ function pad(num) {
10
return stringNum;
11
}
12
13
-function formatAs12HourClock(time) {
+function formatAs12HourClock(time = "") {
14
+ if (typeof time != "string") {
15
+ return "Not a valid format"; //check if time is a string
16
+ }
17
if (
18
(time.indexOf(":") === -1 && time.indexOf(".") === -1) ||
19
(time.indexOf(":") !== -1 && time.indexOf(".") !== -1)
@@ -53,7 +56,9 @@ function formatAs12HourClock(time) {
53
56
hours >= 24 ||
54
57
hours < 0 ||
55
58
minutes >= 60 ||
- minutes < 0
59
+ minutes < 0 ||
60
+ hours % 1 != 0 ||
61
+ minutes % 1 != 0
62
) {
63
return "Not a valid time";
64
} //check if numbers are valid
0 commit comments