Skip to content

Commit e09db2b

Browse files
committed
testing for bugs
1 parent 1b7b0d7 commit e09db2b

1 file changed

Lines changed: 72 additions & 6 deletions

File tree

‎Sprint-3/5-stretch-extend/format-time.js‎

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,84 @@ function formatAs12HourClock(time) {
88
return `${hours - 12}:00 pm`;
99
}
1010
return `${time} am`;
11-
}
11+
}
12+
// console.log(formatAs12HourClock("10:15"));
1213

13-
const currentOutput = formatAs12HourClock("08:00");
14-
const targetOutput = "08:00 am";
14+
// Early Morning: ================> assertion passed
15+
let currentOutput = formatAs12HourClock("08:30");
16+
let targetOutput = "08:30 am";
1517
console.assert(
1618
currentOutput === targetOutput,
17-
`current output: ${currentOutput}, target output: ${targetOutput}`
19+
`current output: ${currentOutput}, target output: ${targetOutput}`
1820
);
21+
console.log(formatAs12HourClock("08:30"))
1922

20-
const currentOutput2 = formatAs12HourClock("23:00");
21-
const targetOutput2 = "11:00 pm";
23+
// Mid-morning ==============> assertion passed
24+
currentOutput = formatAs12HourClock("10:00");
25+
targetOutput = "10:00 am";
26+
console.assert(
27+
currentOutput === targetOutput,
28+
`current output: ${currentOutput}, target output: ${targetOutput}`
29+
);
30+
console.log(formatAs12HourClock("10.00"))
31+
32+
// Late morning ============> assertion passed
33+
currentOutput = formatAs12HourClock("11:45");
34+
targetOutput = "11:45 am";
35+
console.assert(
36+
currentOutput === targetOutput,
37+
`current output: ${currentOutput}, target output: ${targetOutput}`
38+
);
39+
console.log(formatAs12HourClock("11.45"))
40+
41+
42+
// Afternoon =============> assertion failed
43+
let currentOutput2 = formatAs12HourClock("12:00");
44+
let targetOutput2 = "12:00 pm";
2245
console.assert(
2346
currentOutput2 === targetOutput2,
2447
`current output: ${currentOutput2}, target output: ${targetOutput2}`
2548
);
49+
console.log(formatAs12HourClock("12:00"))
50+
51+
// Early afternoon =============> assertion passed
52+
currentOutput2 = formatAs12HourClock("14:00");
53+
targetOutput2 = "02:00 pm";
54+
console.assert(
55+
currentOutput2 === targetOutput2,
56+
`current output: ${currentOutput2}, target output: ${targetOutput2}`
57+
);
58+
console.log(formatAs12HourClock("14:00"))
59+
60+
// Mid afternoon =============> time display doesn't correspond
61+
currentOutput2 = formatAs12HourClock("15:30");
62+
targetOutput2 = "03:30 pm";
63+
console.assert(
64+
currentOutput2 === targetOutput2,
65+
`current output: ${currentOutput2}, target output: ${targetOutput2}`
66+
);
67+
console.log(formatAs12HourClock("15:30"))
68+
69+
// Towards evening ==============> time display doesn't correspond
70+
currentOutput2 = formatAs12HourClock("17:30");
71+
targetOutput2 = "05:30 pm";
72+
console.assert(
73+
currentOutput2 === targetOutput2,
74+
`current output: ${currentOutput2}, target output: ${targetOutput2}`
75+
);
76+
console.log(formatAs12HourClock("17:30"))
77+
78+
// Late night =============> assertion passed
79+
currentOutput2 = formatAs12HourClock("23:00");
80+
targetOutput2 = "11:00 pm";
81+
console.assert(
82+
currentOutput2 === targetOutput2,
83+
`current output: ${currentOutput2}, target output: ${targetOutput2}`
84+
);
85+
console.log(formatAs12HourClock("23:00"))
86+
87+
88+
89+
90+
91+

0 commit comments

Comments
 (0)