Skip to content

Commit 411575d

Browse files
Add interpretation answers for 2-time-format.js
1 parent fa5c077 commit 411575d

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,42 @@ 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+
// ─────────────────────────────────────────────────────────────
28+
// QUESTION a) How many variable declarations?
29+
// ANSWER: 7
30+
// Line 1 → movieLength
31+
// Line 3 → remainingSeconds
32+
// Line 4 → totalMinutes
33+
// Line 6 → remainingMinutes
34+
// Line 7 → totalHours
35+
// Line 9 → result
36+
// (console.log on Line 10 is a function call, not a declaration.)
37+
//
38+
// QUESTION b) How many function calls?
39+
// ANSWER: 1 → console.log(result) on Line 10.
40+
//
41+
// QUESTION c) What does movieLength % 60 mean?
42+
// ANSWER: % is the "remainder" operator. It tells you what's left over
43+
// after dividing by 60. Since there are 60 seconds in a minute,
44+
// the remainder is the seconds that don't fill a full minute.
45+
// Example: 8784 % 60 = 24 (so 24 seconds left over).
46+
//
47+
// QUESTION d) What does Line 4 do?
48+
// ANSWER: Subtracts the leftover seconds first, then divides by 60.
49+
// Subtracting first avoids getting a decimal.
50+
// (8784 - 24) / 60 = 146 total minutes.
51+
//
52+
// QUESTION e) What does `result` represent?
53+
// ANSWER: The movie length written as hours:minutes:seconds — the same
54+
// format YouTube and video players use. Useful for timers,
55+
// countdowns, workout apps, etc.
56+
//
57+
// QUESTION f) Does it work with different values?
58+
// ANSWER: Yes. Tested values:
59+
// 60 → 0:1:0
60+
// 59 → 0:0:59
61+
// 3661 → 1:1:1
62+
// 3600 → 1:0:0
63+
// It works for any whole, positive number of seconds.
64+
// ─────────────────────────────────────────────────────────────

0 commit comments

Comments
 (0)