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 @@ -11,11 +11,13 @@ function formatAs12HourClock(time) {
1111 if ( hours >= 12 ) {
1212 suffix = "pm" ;
1313 }
14+
1415 let formattedHours = hours % 12 ;
1516
1617 if ( formattedHours === 0 ) {
1718 formattedHours = 12 ;
1819 }
20+
1921 return `${ formattedHours } :${ minutes } ${ suffix } ` ;
2022}
2123
@@ -32,6 +34,7 @@ console.assert(
3234 currentOutput2 === targetOutput2 ,
3335 `current output: ${ currentOutput2 } , target output: ${ targetOutput2 } ` ,
3436) ;
37+
3538const noonOutput = formatAs12HourClock ( "12:00" ) ;
3639const noonTarget = "12:00 pm" ;
3740console . assert (
@@ -45,4 +48,11 @@ console.assert(
4548 midnightOutput === midnightTarget ,
4649 `current output: ${ midnightOutput } , target output: ${ midnightTarget } ` ,
4750) ;
48- console . log ( "All tests passed" ) ;
51+
52+ const minuteOutput = formatAs12HourClock ( "13:05" ) ;
53+ const minuteTarget = "01:05 pm" ;
54+ console . assert (
55+ minuteOutput === minuteTarget ,
56+ `current output: ${ minuteOutput } , target output: ${ minuteTarget } ` ,
57+ ) ;
58+ console . log ( "all tests passed" ) ;
You can’t perform that action at this time.
0 commit comments