File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
Sprint-2/5-stretch-extend Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 44
55function formatAs12HourClock ( time ) {
66 const hours = Number ( time . slice ( 0 , 2 ) ) ;
7+ const minutes = time . slice ( 3 ) ;
8+ console . log ( minutes ) ;
9+ if ( hours == 12 ) {
10+ return `${ hours } :${ minutes } pm` ;
11+ }
12+
713 if ( hours > 12 ) {
8- return `${ hours - 12 } :00 pm` ;
14+ return `${ hours - 12 } :${ minutes } pm` ;
915 }
1016 return `${ time } am` ;
1117}
@@ -23,3 +29,17 @@ console.assert(
2329 currentOutput2 === targetOutput2 ,
2430 `current output: ${ currentOutput2 } , target output: ${ targetOutput2 } `
2531) ;
32+
33+ const currentOutput3 = formatAs12HourClock ( "23:30" ) ;
34+ const targetOutput3 = "11:30 pm" ;
35+ console . assert (
36+ currentOutput3 === targetOutput3 ,
37+ `current output: ${ currentOutput3 } , target output: ${ targetOutput3 } `
38+ ) ;
39+
40+ const currentOutput4 = formatAs12HourClock ( "12:01" ) ;
41+ const targetOutput4 = "12:01 pm" ;
42+ console . assert (
43+ currentOutput4 === targetOutput4 ,
44+ `current output: ${ currentOutput4 } , target output: ${ targetOutput4 } `
45+ ) ;
You can’t perform that action at this time.
0 commit comments