Skip to content

Commit 2f89dbe

Browse files
completed 2-time-format.js
1 parent 3df39c3 commit 2f89dbe

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

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

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

9-
const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`;
10-
console.log(result);
9+
const timeRemainingHHMMSS = `${totalHours}:${remainingMinutes}:${remainingSeconds}`;
10+
console.log(timeRemainingHHMMSS);
1111

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+
// i) There are 5 variable declerations. Lines 1, 3, 4, 6, 7 and 9
1516

1617
// b) How many function calls are there?
18+
// ii) There is only one function call. Line 10
1719

1820
// c) Using documentation, explain what the expression movieLength % 60 represents
1921
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
22+
// iii) the % is a remainder operator telling us how many remaining seconds are left in the variable decleration in line 1
2023

2124
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
25+
// iv) line 4 is taking the movieLength 8784 - remainingSeconds 24 which leaves us with a whole value of 146 for the totalMinutes variable decleration.
2226

2327
// e) What do you think the variable result represents? Can you think of a better name for this variable?
28+
// v) It represents the total time remaining in HH:MM:SS format, perhaps changing variable decleration to timeRemainingHHMMSS would be more descriptive in what we are trying to achieve?
2429

2530
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
31+
// vi) this code won't work for negative number values and non-numeric values, I noticed that single-digit values don't follow the HHMMSS it shows HMSS depending on the value input used such as movieLength = 52.

0 commit comments

Comments
 (0)