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
//modulo operator returns left over after division. the expession movieLength % 60 returns the
23
+
// remaining seconds after dividing the movieLength by 60. In this case, it returns 24, which is the remaining seconds after dividing 8784 by 60.
21
24
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
22
-
25
+
// the expression covert the movieLength from seconds to minutes.
26
+
// it subtracts the remaining seconds from the movieLength and divides the result by 60 to get the total minutes. In this case, it returns 146, which is the total minutes of the movie length.
23
27
// e) What do you think the variable result represents? Can you think of a better name for this variable?
24
-
28
+
// the total length of movie in hours,minutes and seconds.
29
+
// a better name movieLengthHMS would be more clear.
25
30
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
31
+
// No, it will not work for all values of movieLength.
32
+
// if movieLength is above 24 hours, the code will create an incorrect format of hours.
);// removes the last character "p" from the penceString and stores the result in a new variable called penceStringWithoutTrailingP. The substring method is used to extract a portion of the string, starting from index 0 and ending at the second-to-last index (length - 1).
//padStart method is used to add leading zeros to the penceStringWithoutTrailingP until it reaches a length of 3 characters. The result is stored in a new variable called paddedPenceNumberString.
0 commit comments