Skip to content

Commit ac9bd5d

Browse files
committed
Implement function to track first number passed to pad function
1 parent 0fe7ef9 commit ac9bd5d

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
// let padCalls = 0;
2+
let padCallCount = 0;
3+
let firstNum;
4+
25
function pad(num) {
36
// padCalls++;
7+
padCallCount++;
8+
if (padCallCount === 1){
9+
firstNum = num;
10+
}
411
let numString = num.toString();
512
while (numString.length < 2) {
613
numString = "0" + numString;
@@ -21,6 +28,8 @@ function formatTimeDisplay(seconds) {
2128
// const result = formatTimeDisplay(s);
2229
// console.log(`formatTimeDisplay(${s})==> ${result}| pad called ${padCalls} times `);
2330
// }
31+
formatTimeDisplay(61);
32+
console.log("The value assigned to num on the first call to pad is:", firstNum);
2433

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

0 commit comments

Comments
 (0)