File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Sprint-2/5-stretch-extend Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 55function formatAs12HourClock ( time ) {
66 const hours = Number ( time . slice ( 0 , 2 ) ) ;
77 const minutes = time . slice ( 3 ) ;
8- console . log ( minutes ) ;
8+
99 if ( hours == 12 ) {
1010 return `${ hours } :${ minutes } pm` ;
1111 }
1212
1313 if ( hours > 12 ) {
1414 return `${ hours - 12 } :${ minutes } pm` ;
1515 }
16+
17+ if ( hours === 0 ) {
18+ return `12:${ minutes } am` ;
19+ }
20+
1621 return `${ time } am` ;
1722}
1823
19- const currentOutput = formatAs12HourClock ( "08:00 " ) ;
20- const targetOutput = "08:00 am" ;
24+ const currentOutput = formatAs12HourClock ( "00:30 " ) ;
25+ const targetOutput = "12:30 am" ;
2126console . assert (
2227 currentOutput === targetOutput ,
2328 `current output: ${ currentOutput } , target output: ${ targetOutput } `
2429) ;
2530
26- const currentOutput2 = formatAs12HourClock ( "23:00 " ) ;
27- const targetOutput2 = "11:00 pm" ;
31+ const currentOutput2 = formatAs12HourClock ( "13:01 " ) ;
32+ const targetOutput2 = "1:01 pm" ;
2833console . assert (
2934 currentOutput2 === targetOutput2 ,
3035 `current output: ${ currentOutput2 } , target output: ${ targetOutput2 } `
You can’t perform that action at this time.
0 commit comments