File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Sprint-2/5-stretch-extend Expand file tree Collapse file tree 1 file changed +5
-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 , 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" ) )
2020const currentOutput = formatAs12HourClock ( "08:00" ) ;
21- const targetOutput = "08 :00 am" ;
21+ const targetOutput = "8 :00 am" ;
2222console . assert (
2323 currentOutput === targetOutput ,
2424 `current output: ${ currentOutput } , target output: ${ targetOutput } `
You can’t perform that action at this time.
0 commit comments