Skip to content

Commit 4982dbf

Browse files
Answer all the question
1 parent 14c0fe3 commit 4982dbf

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,26 @@ console.log(result);
1212
// For the piece of code above, read the code and then answer the following questions
1313

1414
// a) How many variable declarations are there in this program?
15-
15+
// 6
1616
// b) How many function calls are there?
17-
17+
// 1
1818
// c) Using documentation, explain what the expression movieLength % 60 represents
1919
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
2020

21+
//movieLength % 60 returns the remaining seconds after converting total seconds into full minutes.
22+
2123
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
2224

25+
//It subtracts the leftover seconds (remainingSeconds) from the total movie length (movieLength) to get the number of seconds that make up complete minutes, and then divides by 60 to convert those seconds into total minutes.
26+
2327
// e) What do you think the variable result represents? Can you think of a better name for this variable?
2428

29+
//result is too general — it does not tell what the value means.
30+
//The variable result represents the movie running time in hours, minutes, and seconds (HH:MM:SS)
31+
//A better variable name would be movieRunTime or formattedRunTime.
32+
2533
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
34+
35+
//Yes, this code works for all positive integer values of movieLength.
36+
//It converts seconds into hours, minutes, and seconds using division and remainder.
37+
//For example, when movieLength = 5550, the result is 1:32:30.

0 commit comments

Comments
 (0)