Skip to content

Commit 5e0afc9

Browse files
committed
format.js
1 parent a1a3870 commit 5e0afc9

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

‎Sprint-3/5-stretch-extend/format-time.js‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// return `${hours - 12}:00 pm`;
99
// }
1010
// return `${time} am`;
11-
// }
11+
// }
1212
// // console.log(formatAs12HourClock("10:15"));
1313

1414
// // Early Morning: ================> assertion passed
@@ -38,7 +38,6 @@
3838
// );
3939
// console.log(formatAs12HourClock("11.45"))
4040

41-
4241
// // Afternoon =============> assertion failed
4342
// let currentOutput2 = formatAs12HourClock("12:00");
4443
// let targetOutput2 = "12:00 pm";
@@ -84,7 +83,6 @@
8483
// );
8584
// console.log(formatAs12HourClock("23:00"))
8685

87-
8886
// Test result:
8987
// Hours and Minutes worked in the AM function for different time test.
9088
// 12:00 in the afternoon doesn't function correctly
@@ -98,15 +96,14 @@ function formatAs12HourClock(time) {
9896
const minutes = time.slice(3, 5);
9997

10098
if (hours === 0) {
101-
return `12:${minutes} am`
99+
return `12:${minutes} am`;
102100
}
103101
if (hours === 12) {
104102
return `12:${minutes} pm`;
105103
}
106104
if (hours > 12) {
107105
return `${String(hours - 12).padStart(2, "0")}:${minutes} pm`;
108106
}
109-
110107

111108
return `${time} am`;
112109
}
@@ -115,16 +112,16 @@ const currentOutput = formatAs12HourClock("01:00");
115112
const targetOutput = "01:00 am";
116113
console.assert(
117114
currentOutput === targetOutput,
118-
`current output: ${currentOutput}, target output: ${targetOutput}`
115+
`current output: ${currentOutput}, target output: ${targetOutput}`,
119116
);
120-
console.log(formatAs12HourClock("01:00"))
117+
console.log(formatAs12HourClock("01:00"));
121118

122119
const currentOutput2 = formatAs12HourClock("19:30");
123120
const targetOutput2 = "07:30 pm";
124121

125122
console.assert(
126123
currentOutput2 === targetOutput2,
127-
`current output: ${currentOutput2}, target output: ${targetOutput2}`
124+
`current output: ${currentOutput2}, target output: ${targetOutput2}`,
128125
);
129126

130127
console.log(formatAs12HourClock("19:30"));

0 commit comments

Comments
 (0)