File tree Expand file tree Collapse file tree
Sprint-3/5-stretch-extend Expand file tree Collapse file tree 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+ const formattedMinutes = minutes . padStart ( 2 , "0" ) ;
89
910 if ( hours > 12 ) {
10- return `${ hours - 12 } :${ minutes . toString ( ) . padStart ( 2 , "0" ) } pm` ;
11+ return `${ hours - 12 } :${ formattedMinutes } pm` ;
1112 }
1213 if ( hours === 12 ) {
13- return `${ hours } :${ minutes . toString ( ) . padStart ( 2 , "0" ) } pm` ;
14+ return `${ hours } :${ formattedMinutes } pm` ;
1415 }
1516 if ( hours === 0 ) {
16- return `12:${ minutes . toString ( ) . padStart ( 2 , "0" ) } am` ;
17+ return `12:${ formattedMinutes } am` ;
1718 }
18- return `${ hours } :${ minutes . toString ( ) . padStart ( 2 , "0" ) } am` ;
19+ return `${ hours } :${ formattedMinutes } am` ;
1920}
2021
2122const currentOutput = formatAs12HourClock ( "08:00" ) ;
You can’t perform that action at this time.
0 commit comments