@@ -10,16 +10,65 @@ function formatAs12HourClock(time) {
1010 return `${ time } am` ;
1111}
1212
13+ //current = what the code did
14+ //target = what i wanted it to do
15+
1316const currentOutput = formatAs12HourClock ( "08:00" ) ;
1417const targetOutput = "08:00 am" ;
1518console . assert (
1619 currentOutput === targetOutput ,
17- `current output: ${ currentOutput } , target output: ${ targetOutput } `
20+ `current output: ${ currentOutput } , target output: ${ targetOutput } ` ,
1821) ;
1922
2023const currentOutput2 = formatAs12HourClock ( "23:00" ) ;
2124const targetOutput2 = "11:00 pm" ;
2225console . assert (
2326 currentOutput2 === targetOutput2 ,
24- `current output: ${ currentOutput2 } , target output: ${ targetOutput2 } `
27+ `current output: ${ currentOutput2 } , target output: ${ targetOutput2 } ` ,
28+ ) ;
29+
30+ const currentOutput3 = formatAs12HourClock ( "12:00" ) ;
31+ const targetOutput3 = "12:00 pm" ;
32+ console . assert (
33+ currentOutput3 === targetOutput3 ,
34+ `current output: ${ currentOutput3 } , target output: ${ targetOutput3 } ` ,
35+ ) ;
36+ const currentOutput4 = formatAs12HourClock ( "23:00" ) ;
37+ const targetOutput4 = "11:59 pm" ;
38+ console . assert (
39+ currentOutput4 === targetOutput4 ,
40+ `current output: ${ currentOutput4 } , target output: ${ targetOutput4 } ` ,
41+ ) ;
42+
43+ const currentOutput5 = formatAs12HourClock ( "00:00" ) ;
44+ const targetOutput5 = "00:00 am" ;
45+ console . assert (
46+ currentOutput5 === targetOutput5 ,
47+ `current output: ${ currentOutput5 } , target output: ${ targetOutput5 } ` ,
48+ ) ;
49+
50+ const currentOutput6 = formatAs12HourClock ( "00:30" ) ;
51+ const targetOutput6 = "00:30 am" ;
52+ console . assert (
53+ currentOutput6 === targetOutput6 ,
54+ `current output: ${ currentOutput6 } , target output: ${ targetOutput6 } ` ,
55+ ) ;
56+
57+ const currentOutput7 = formatAs12HourClock ( "14:00" ) ;
58+ const targetOutput7 = "14:30 pm" ;
59+ console . assert (
60+ currentOutput7 === targetOutput7 ,
61+ `current output: ${ currentOutput7 } , target output: ${ targetOutput7 } ` ,
62+ ) ;
63+
64+ const currentOutput7 = formatAs12HourClock ( "15:00" ) ;
65+ const targetOutput7 = "15:30 pm" ;
66+ console . assert (
67+ currentOutput7 === targetOutput7 ,
68+ `current output: ${ currentOutput7 } , target output: ${ targetOutput7 } ` ,
2569) ;
70+ console . log ( ) ;
71+ //Edge cases noticed:
72+ // minutes are ignored in the formatAs12HourClock function after 12 so all pm hours are printed incorrectly because minutes hasn't been stored anywhere in the function.
73+ // 12 should return 12:00pm but it returns 12:00am in the function
74+ // 00:00am should return 12:00am
0 commit comments