We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f7c0a35 commit 23a25caCopy full SHA for 23a25ca
Sprint-2/5-stretch-extend/format-time.js
@@ -6,7 +6,7 @@ function formatAs12HourClock(time) {
6
const hours = Number(time.slice(0, 2));
7
const minutes = time.slice(3, 5);
8
if (hours >= 12) {
9
- return `${hours - 12}:${minutes} pm`;
+ return `${hours !== 12 ? hours - 12 : hours}:${minutes} pm`;
10
}
11
return `${time} am`;
12
@@ -90,8 +90,8 @@ console.assert(
90
);
91
92
// Edge: single digit hour
93
-const outSingle = formatAs12HourClock("7:00");
94
-const targetSingle = "7:00 am";
+const outSingle = formatAs12HourClock("7:45");
+const targetSingle = "7:45 am";
95
console.assert(
96
outSingle === targetSingle,
97
`current output: ${outSingle}, target output: ${targetSingle}`
0 commit comments