Skip to content

Commit d899f9a

Browse files
authored
Refine comments for clarity in time format logic
Updated comments to clarify variable declarations, function calls, and expressions in the time format calculation.
1 parent 256c58a commit d899f9a

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,21 @@ 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-
15+
// There are 7 variable declarations: movieLength, remainingSeconds, totalMinutes, remainingMinutes, totalHours, result
1616
// b) How many function calls are there?
17-
17+
// There is 1 function call: console.log(result)
1818
// c) Using documentation, explain what the expression movieLength % 60 represents
1919
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
20+
// The % operator is the remainder operator. movieLength % 60 finds the remainder after dividing movieLength by 60.
2021

2122
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
22-
23+
// Calculate the total number of complete minutes.
24+
// First, subtract the remaining seconds from the movie length,
25+
// leaving a number that can be divided exactly by 60.
26+
// Then divide by 60 to convert seconds into minutes.
2327
// e) What do you think the variable result represents? Can you think of a better name for this variable?
24-
28+
// result represents the movie length converted from seconds into hours, minutes and seconds.
2529
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
30+
// The code works correctly for positive whole numbers of seconds.
31+
// However, it may not give a useful result for negative numbers,
32+
// decimals, or values that are not numbers.

0 commit comments

Comments
 (0)