Skip to content

Commit 405be77

Browse files
committed
corrected the answers and updated code to add leading 0 when values are less than 10
1 parent fbf9e94 commit 405be77

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ const totalMinutes = (movieLength - remainingSeconds) / 60;
66
const remainingMinutes = totalMinutes % 60;
77
const totalHours = (totalMinutes - remainingMinutes) / 60;
88

9-
const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`;
9+
const result = `${String(totalHours).padStart(2, "0")}:${String(
10+
remainingMinutes
11+
).padStart(2, "0")}:${String(remainingSeconds).padStart(2, "0")}`;
1012
console.log(result);
1113

1214
// For the piece of code above, read the code and then answer the following questions
@@ -15,7 +17,7 @@ console.log(result);
1517
// there are 6 variable declarations in this program. They are on lines 1, 3, 4, 6, 7 and 9
1618

1719
// b) How many function calls are there?
18-
// there are 2 function calls in this program. They are on lines 9 and 10
20+
// there is 1 function calls in this program. And it is on line 10
1921

2022
// c) Using documentation, explain what the expression movieLength % 60 represents
2123
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
@@ -27,7 +29,7 @@ seconds and then dividing that result by 60.*/
2729

2830
// e) What do you think the variable result represents? Can you think of a better name for this variable?
2931
/* the variable result represents the total length of the movie in hours, minutes and seconds. A better name for this variable could
30-
be movieDuration.*/
32+
be formattedmovieDuration.*/
3133

3234
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
3335
// yes this code will work for all values of movieLength as long as the value is a non-negative integer representing the length of a movie in seconds.

0 commit comments

Comments
 (0)