Skip to content

Commit 4c05247

Browse files
committed
Add logging to track pad function calls in formatTimeDisplay
1 parent 93a453c commit 4c05247

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎Sprint-3/4-mandatory-interpret/time-format.js‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
let padCalls = 0;
12
function pad(num) {
3+
padCalls++;
24
let numString = num.toString();
35
while (numString.length < 2) {
46
numString = "0" + numString;
@@ -14,6 +16,12 @@ function formatTimeDisplay(seconds) {
1416

1517
return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`;
1618
}
19+
for (const s of [8784, 77, 77777]){
20+
padCalls = 0;
21+
const result = formatTimeDisplay(s);
22+
console.log(`formatTimeDisplay(${s})==> ${result}| pad called ${padCalls} times `);
23+
}
24+
console.log
1725

1826
// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
1927
// to help you answer these questions

0 commit comments

Comments
 (0)