Skip to content

Commit a469ac4

Browse files
committed
explaining the code
1 parent 8f7878f commit a469ac4

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,19 @@ console.log(result);
2323
// e) What do you think the variable result represents? Can you think of a better name for this variable?
2424

2525
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
26+
27+
// Answer
28+
29+
// a) In the above code there are 6 variable declarations
30+
31+
// b) There is only 1 function call in the code
32+
33+
// c) the expression movieLength % 60 is trying to divide the movieLength by 60 then get the remainder
34+
35+
// d) totalMinutes = (movieLength - remainingSeconds) / 60 in this expression
36+
// 1. (movieLength - remainingSeconds) the values inside the parenthesis is calculated first then it is divided by 60
37+
// then the value of expression is assigned to the var totalMinutes
38+
39+
// e) the variable result represents the formatted time in hours:minutes:seconds. I would rename it time
40+
41+
// f) it will not work with negative numbers because we can not have negative time

0 commit comments

Comments
 (0)