Skip to content

Commit 313ea73

Browse files
author
russom
committed
Pad and formatTimeDisplay functions explained what output they have at different stages.
1 parent 7e1a0bf commit 313ea73

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Sprint-2/4-mandatory-interpret/time-format.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,26 @@ function formatTimeDisplay(seconds) {
2323
// a) When formatTimeDisplay is called how many times will pad be called?
2424
// =============> write your answer here
2525

26+
// pad will be called 3 times when formatTimeDisplay is called. Once for totalHours, once for remainingMinutes and one for remainingSeconds.
27+
2628
// Call formatTimeDisplay with an input of 61, now answer the following:
2729

2830
// b) What is the value assigned to num when pad is called for the first time?
2931
// =============> write your answer here
3032

33+
// The value assigned to num when pad is called for the first time is 0. This is because totalHours is calculated as (totalMinutes - remainingMinutes) / 60, which results in 0 when the input is 61 seconds.
34+
3135
// c) What is the return value of pad is called for the first time?
3236
// =============> write your answer here
3337

38+
// The return value of pad when it is called for the first time is 00. this is because the value of num is 0 and the pad function adds a 0 to the front of the string until the num characters has at least 2 characters.
39+
3440
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
3541
// =============> write your answer here
3642

43+
//The value assigned to num when pad is called for the last time is 1. This is because the last call to pad is for remainingSeconds which is calculated as seconds % 60, the result of which is 1.
44+
3745
// e) What is the return value of pad when it is called for the last time in this program? Explain your answer
3846
// =============> write your answer here
47+
48+
// The return value of pad when it is called for the last time is 01. This is because the pad function adds a 0 to the front of the string if the characters of the string are less than 2.

0 commit comments

Comments
 (0)