You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Subtracts the leftover seconds (that couldn’t form a full minute).
51
-
52
-
// Divides the remaining seconds by 60.
53
-
// Meaning:
54
-
// Converts the total movie length into minutes, ignoring any incomplete minute.
55
-
// So it gives the total number of full minutes in the movie.
44
+
// It subtracts the leftover seconds (that couldn’t form a full minute).
45
+
// Then divides the remaining seconds by 60.
46
+
// In doing so it converts the total movie length into minutes, ignoring any incomplete minute giving the total number of full minutes in the movie.
56
47
57
48
// e) What do you think the variable result represents? Can you think of a better name for this variable?
58
49
59
50
// const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`;
60
51
61
52
// This combines hours, minutes, and seconds into a single string formatted like H:M:S.
62
53
// Example output: "2:26:24"
63
-
// Meaning: It represents the formatted time duration of the movie.
54
+
//
64
55
// Better variable names:
65
-
// formattedDuration
66
-
// timeString
67
-
// movieTime
68
-
// durationInHMS
56
+
// actualTime
57
+
// timeAsUsual
58
+
// timeExpected
69
59
70
60
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
71
61
72
62
// It will work correctly for most positive integers, since it’s just converting seconds into hours, minutes, and seconds using division and remainders.
73
63
// However, there are some edge cases:
74
64
// If movieLength = 0:
75
-
// Output: 0:0:0 ✅ Works fine.
65
+
// Output: 0:0:0 Works fine.
76
66
// If movieLength < 60 (less than a minute):
77
67
// Works fine (e.g., 45 → 0:0:45).
78
68
// If movieLength is not an integer (e.g., 87.5):
79
69
// Still works, but decimals might appear in remainingSeconds.
80
70
// If movieLength is negative:
81
-
// The logic breaks — you’d get negative time components ❌.
82
-
// Formatting issue:
71
+
// The time format breaks giving negative time components.
0 commit comments