Skip to content

Commit f214a57

Browse files
committed
pad time output to 2 digits
1 parent 31c3d98 commit f214a57

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

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

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

33
const remainingSeconds = movieLength % 60;
44
const totalMinutes = (movieLength - remainingSeconds) / 60;
55

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(remainingMinutes).padStart(2, "0")}:${String(remainingSeconds).padStart(2, "0")}`;
1010
console.log(result);
1111

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

0 commit comments

Comments
 (0)