Skip to content

Commit 5429088

Browse files
committed
Add additional input groups to reveal bugs
1 parent 0e13a1a commit 5429088

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Sprint-2/5-stretch-extend/format-time.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ function formatAs12HourClock(time) {
77
if (hours > 12) {
88
return `${hours - 12}:00 pm`;
99
}
10+
if (hours === 12) {
11+
return `${hours}:00 pm`;
12+
}
13+
if (hours === 0) {
14+
const minutes = time.slice(3, 5);
15+
return `12:${minutes} am`;
16+
}
1017
return `${time} am`;
1118
}
1219

@@ -23,3 +30,21 @@ console.assert(
2330
currentOutput2 === targetOutput2,
2431
`current output: ${currentOutput2}, target output: ${targetOutput2}`
2532
);
33+
const currentOutput3 = formatAs12HourClock("12:00");
34+
const targetOutput3 = "12:00 pm";
35+
console.assert(
36+
currentOutput3 === targetOutput3,
37+
`current output: ${currentOutput3}, target output: ${targetOutput3}`
38+
);
39+
const currentOutput4 = formatAs12HourClock("00:00");
40+
const targetOutput4 = "12:00 am";
41+
console.assert(
42+
currentOutput4 === targetOutput4,
43+
`current output: ${currentOutput4}, target output: ${targetOutput4}`
44+
);
45+
const currentOutput5 = formatAs12HourClock("00:30");
46+
const targetOutput5 = "12:30 am";
47+
console.assert(
48+
currentOutput5 === targetOutput5,
49+
`current output: ${currentOutput5}, target output: ${targetOutput5}`
50+
);

0 commit comments

Comments
 (0)