Skip to content

Commit 03018e6

Browse files
fix: correct comparison operators and format output for consistency in time formatting
1 parent 9c73a1c commit 03018e6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
function formatAs12HourClock(time) {
66
const hours = Number(time.slice(0, 2));
77
const minutes=time.slice(3,5)
8-
if(hours==0){
8+
if(hours === 0){
99
return `12:${minutes} am`
1010
}
11-
if(hours===12 ){
11+
if(hours === 12 ){
1212
return `${hours}:${minutes} pm`
1313
}
1414
if (hours > 12) {
1515
return `${hours - 12}:${minutes} pm`;
1616
}
17-
return `${time} am`;
17+
return `${hours}:${minutes} am`;
1818
}
19-
19+
console.log(formatAs12HourClock("01:33"))
2020
const currentOutput = formatAs12HourClock("08:00");
21-
const targetOutput = "08:00 am";
21+
const targetOutput = "8:00 am";
2222
console.assert(
2323
currentOutput === targetOutput,
2424
`current output: ${currentOutput}, target output: ${targetOutput}`

0 commit comments

Comments
 (0)