Skip to content

Commit 40e6f4f

Browse files
committed
made the output for 01:01 be 1:01 am, by removing trailing zero
1 parent 321dd76 commit 40e6f4f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,18 @@ function formatAs12HourClock(time) {
1818
return `12:${minutes} am`;
1919
}
2020

21+
if (time.charAt(0) === "0") {
22+
return `${time.slice(1)} am`;
23+
}
24+
2125
return `${time} am`;
2226
}
2327

24-
const currentOutput = formatAs12HourClock("00:30");
25-
const targetOutput = "12:30 am";
28+
console.log(`the 12 hr format for 01:01 is ${formatAs12HourClock("05:01")}`);
29+
console.log(`the 12 hr format for 13:01 is ${formatAs12HourClock("13:01")}`);
30+
31+
const currentOutput = formatAs12HourClock("01:01");
32+
const targetOutput = "1:01 am";
2633
console.assert(
2734
currentOutput === targetOutput,
2835
`current output: ${currentOutput}, target output: ${targetOutput}`

0 commit comments

Comments
 (0)