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
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";
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");
115112const targetOutput = "01:00 am" ;
116113console . 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
122119const currentOutput2 = formatAs12HourClock ( "19:30" ) ;
123120const targetOutput2 = "07:30 pm" ;
124121
125122console . assert (
126123 currentOutput2 === targetOutput2 ,
127- `current output: ${ currentOutput2 } , target output: ${ targetOutput2 } `
124+ `current output: ${ currentOutput2 } , target output: ${ targetOutput2 } ` ,
128125) ;
129126
130127console . log ( formatAs12HourClock ( "19:30" ) ) ;
0 commit comments