Skip to content

Commit 6992670

Browse files
committed
update: explain and comments for clarity in time format calculations sprint -1 of 2-time-format.js
1 parent 7a0b1f7 commit 6992670

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const movieLength = 8784; // length of movie in seconds
1+
const movieLength = 9000; // length of movie in seconds
22

33
const remainingSeconds = movieLength % 60;
44
const totalMinutes = (movieLength - remainingSeconds) / 60;
@@ -12,14 +12,27 @@ console.log(result);
1212
// For the piece of code above, read the code and then answer the following questions
1313

1414
// a) How many variable declarations are there in this program?
15+
//there are 6 variable declarations
16+
// 1. movieLength
17+
// 2. remainingSeconds
18+
// 3. totalMinutes
19+
// 4. remainingMinutes
20+
// 5. totalHours
21+
// 6. result
1522

1623
// b) How many function calls are there?
24+
// their is 1 function call
25+
// console.log(result);
1726

18-
// c) Using documentation, explain what the expression movieLength % 60 represents
27+
// c) Using documentation, explain what the expression movieLength % 60 represents The is expressing remaining number of seconds after converted to 60 seconds
28+
// The expression `movieLength % 60` calculates the remainder when `movieLength` (the length of the movie in seconds)
29+
// This gives the number of seconds that do not complete a full minute, effectively representing the remaining seconds after converting the total movie length into minutes.
1930
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
2031

2132
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
22-
33+
// The expression (movieLength - remainingSeconds) / 60 determines the total number of full minutes in the movie by removing the leftover seconds and then dividing the result by 60.
2334
// e) What do you think the variable result represents? Can you think of a better name for this variable?
24-
35+
//time
36+
// The variable `result` represents the formatted time of the movie in the format "hours:minutes:seconds".
37+
// A better name for this variable could be "movieDuration" to make it clearer that it holds the duration of the movie in a specific format.
2538
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer

0 commit comments

Comments
 (0)