Skip to content

Commit 3f47448

Browse files
committed
Updated explanation for better undestating on how works the remainingSeconds var
1 parent 5ab71ca commit 3f47448

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

Sprint-1/interpret/time-format.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ console.log(result);
3131
3232
b) How many function calls are there?
3333
34+
-------- 4 function calls:
35+
-------- console.log(remainingSeconds);
36+
-------- console.log(totalMinutes);
37+
-------- console.log(remainingMinutes);
3438
-------- console.log(result);
3539
3640
c) Using documentation, explain what the expression movieLength % 60 represents
@@ -41,18 +45,21 @@ console.log(result);
4145
4246
d) Interpret line 4, what does the expression assigned to totalMinutes mean?
4347
44-
-------- This line is taking the leftover remainder in remainingMinutes and leaving just the
45-
total amount that we can divide perfectly in whole number to see how many minutes we have.
48+
-------- This line subtracts remainingSeconds from movieLength to remove the leftover seconds.
49+
Then, it converts the difference into minutes by dividing the result by 60.
50+
This gives the total number of whole minutes in movieLength.
4651
4752
e) What do you think the variable result represents? Can you think of a better name for this variable?
4853
49-
------- Result var represent the total runtime of the movie, the nameVar is fine but we can name it as
50-
timeMovie for better readability, as it gives future readers a better idea of the variable's purpose.
54+
------- Result var represents the total runtime of the movie. While "result" is fine,
55+
a name like "timeMovie" or "formattedTime" would be more descriptive and improve readability.
5156
5257
f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
5358
54-
------- This code works as expected for the most of positive values of movieLength. Just
55-
when I write negative number in the result will show the negative sign. eg.
59+
------- This code works as expected for the most of positive values of movieLength.
60+
However, if a negative value is provided for movieLength, the result will show negative values,
61+
which might not make sense in the context of time. For example:
5662
const movieLength = -4258;
5763
result: -1:-10:-58
64+
5865
*/

0 commit comments

Comments
 (0)