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
// % is a modulo operator that return the remainder of a multiplied number
20
24
21
25
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
26
+
// movieLength subtract the left over seconds from the total seconds(movieLength) to get a number that is divisible by 60
27
+
// when dividing by 60 would convert the remaining seconds into whole minutes which ensures there is no decimal in totalMinutes
28
+
22
29
23
30
// e) What do you think the variable result represents? Can you think of a better name for this variable?
31
+
// results present length of movie formatted as Hours:Minutes:Seconds and a better name could be movieDuration
32
+
24
33
25
34
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
35
+
36
+
// whole positive value: for the 8789 seconds the formatted duration would be fine 2:26:29 and the code would be working as expected
37
+
// under 60 seconds: 59 seconds would assign the hours and minutes both as 0s resulting 0:0:59 instead of the normal formatted way 00:00:59 but still correct
38
+
// zero value: the formatted duration would also be correct 0:0:0 even though it is an unusual value it still show that it can handle it
39
+
// Negative value: for the -8789 seconds would give us an output of -2:-26:-29 which is not a valid format and doesn't make any sense
40
+
// the logic breaks where we need to give the user a message to enter a valid number
0 commit comments