Skip to content

Commit 1bf7cd3

Browse files
committed
fix errors in time
1 parent 5775809 commit 1bf7cd3

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ const totalHours = (totalMinutes - remainingMinutes) / 60;
88

99
const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`;
1010
console.log(result);
11-
// There are 6 variables declared in this program: movieLength, remainingSeconds, totalMinutes, remainingMinutes, totalHours, and result.
12-
// There are 4 function calls in this program: console.log(), and the three arithmetic operations used to calculate remainingSeconds, totalMinutes, and remainingMinutes.
13-
// The expression movieLength % 60 calculates the remainder when movieLength is divided by 60. This gives the number of seconds remaining after converting the total length of the movie into minutes and hours.
14-
// Interpret line 4, the expression assigned to totalMinutes calculates the total number of minutes in the movie by subtracting the remaining seconds from the total length of the movie and dividing by 60.
15-
// The variable result represents the formatted string of the movie length in hours, minutes, and seconds. A better name for this variable could be formattedMovieLength or movieLengthString.
16-
// This code will work for all values of movieLength, as it correctly calculates the hours, minutes, and seconds regardless of the total length of the movie. However, if movieLength is negative, it may not produce a meaningful result.
17-
// experimenting with different values of movieLength, such as 2:25.833, 1:23:20, will show that the code correctly formats the length of the movie in hours, minutes, and seconds for all positive values.
1811

1912
// For the piece of code above, read the code and then answer the following questions
2013

@@ -30,3 +23,11 @@ console.log(result);
3023
// e) What do you think the variable result represents? Can you think of a better name for this variable?
3124

3225
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
26+
27+
//There are 6 variables declared in this program: movieLength, remainingSeconds, totalMinutes, remainingMinutes, totalHours, and result.
28+
// There is 1 function calls in this program: console.log(), and the three arithmetic operations used to calculate remainingSeconds, totalMinutes, and remainingMinutes.
29+
// The expression movieLength % 60 calculates the remainder when movieLength is divided by 60. This gives the number of seconds remaining after converting the total length of the movie into minutes and hours.
30+
// Interpret line 4, the expression assigned to totalMinutes calculates the total number of minutes in the movie by subtracting the remaining seconds from the total length of the movie and dividing by 60.
31+
// The variable result represents the formatted string of the movie length in hours, minutes, and seconds. A better name for this variable could be formattedMovieLength or movieLengthString.
32+
// This code will work for all values of movieLength.
33+
// experimenting with different values of movieLength, such as 1:51:6, 0:55:33 etc., will show that the code correctly formats the length of the movie in hours, minutes, and seconds for all positive values.

0 commit comments

Comments
 (0)