Skip to content

Commit 496d1b8

Browse files
committed
Enhance comments for clarity on variable declarations, function calls, and calculations in time formatting
1 parent b06aae3 commit 496d1b8

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,32 @@ 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+
//1.movieLength
16+
//2.remainingSeconds
17+
//3.totalMinutes
18+
//4.remainingMinutes
19+
//5.totalHours
20+
//6.result
1521

1622
// b) How many function calls are there?
23+
//1. Line 10: console.log(result)
1724

1825
// c) Using documentation, explain what the expression movieLength % 60 represents
1926
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
2027

28+
//The % symbol is called the modulus operator. It returns the remainder of a division operation.
29+
// In this case, movieLength % 60 calculates the remaining seconds after dividing the total movie length by 60 (the number of seconds in a minute).
30+
// This gives us the number of seconds that do not make up a full minute in the movie length.
31+
2132
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
33+
// The expression (movieLength - remainingSeconds) / 60 calculates the total number of minutes in the movie by subtracting the remaining seconds from the total seconds
34+
// and then dividing by 60.
2235

2336
// e) What do you think the variable result represents? Can you think of a better name for this variable?
37+
// The variable result represents the formatted time of the movie in hours, minutes, and seconds. A better name for this variable could be movieDuration.
2438

2539
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
40+
//It will do the math perfectly for most normal positive numbers, but there are a few situations where the code will act wierdly.
41+
//1. Visual problems
42+
//2. Negative numbers
43+
//3.Decimal numbers

0 commit comments

Comments
 (0)