Skip to content

Commit b5a85c1

Browse files
committed
answering interpret 2-time-format
1 parent 08355c3 commit b5a85c1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,37 @@ const totalHours = (totalMinutes - remainingMinutes) / 60;
88

99
const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`;
1010
console.log(result);
11+
console.log(remainingSeconds)
1112

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

1415
// a) How many variable declarations are there in this program?
1516

17+
// There are 6 variable declarations
18+
1619
// b) How many function calls are there?
1720

21+
// There is 1 function call
22+
1823
// c) Using documentation, explain what the expression movieLength % 60 represents
1924
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
2025

26+
// % is a remainder operator.
27+
// movieLength % 60 represents the remainder when 8784/60 is calculated, which is 24 seconds
28+
2129
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
2230

31+
// The expression is calculating the total number of minutes in the movie length
32+
// It does this by subtracting the remaining seconds from the total movie length, and then dividing it by 60
33+
2334
// e) What do you think the variable result represents? Can you think of a better name for this variable?
2435

36+
// The result represents the movie length in hours:minutes:seconds
37+
// A better name could be hoursMinutesSeconds or movieLengthFormatted
38+
2539
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
40+
41+
// The code will only work for positive integers
42+
// if the value is 0 or negative, the code will not make sense
43+
// if the value is a decimal, the code will give float results
44+
// if the value is not a number, the code will give an error

0 commit comments

Comments
 (0)